diff options
Diffstat (limited to 'Source/JavaScriptCore/yarr/YarrInterpreter.h')
-rw-r--r-- | Source/JavaScriptCore/yarr/YarrInterpreter.h | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/Source/JavaScriptCore/yarr/YarrInterpreter.h b/Source/JavaScriptCore/yarr/YarrInterpreter.h index fb60bd979..bb64e6d91 100644 --- a/Source/JavaScriptCore/yarr/YarrInterpreter.h +++ b/Source/JavaScriptCore/yarr/YarrInterpreter.h @@ -337,42 +337,37 @@ public: struct BytecodePattern { WTF_MAKE_FAST_ALLOCATED; public: - BytecodePattern(PassOwnPtr<ByteDisjunction> body, Vector<ByteDisjunction*> allParenthesesInfo, YarrPattern& pattern, BumpPointerAllocator* allocator) + BytecodePattern(PassOwnPtr<ByteDisjunction> body, Vector<OwnPtr<ByteDisjunction> >& parenthesesInfoToAdopt, YarrPattern& pattern, BumpPointerAllocator* allocator) : m_body(body) , m_ignoreCase(pattern.m_ignoreCase) , m_multiline(pattern.m_multiline) , m_allocator(allocator) { + m_body->terms.shrinkToFit(); + newlineCharacterClass = pattern.newlineCharacterClass(); wordcharCharacterClass = pattern.wordcharCharacterClass(); - m_allParenthesesInfo.append(allParenthesesInfo); - m_userCharacterClasses.append(pattern.m_userCharacterClasses); - // 'Steal' the YarrPattern's CharacterClasses! We clear its - // array, so that it won't delete them on destruction. We'll - // take responsibility for that. - pattern.m_userCharacterClasses.clear(); - } + m_allParenthesesInfo.swap(parenthesesInfoToAdopt); + m_allParenthesesInfo.shrinkToFit(); - ~BytecodePattern() - { - deleteAllValues(m_allParenthesesInfo); - deleteAllValues(m_userCharacterClasses); + m_userCharacterClasses.swap(pattern.m_userCharacterClasses); + m_userCharacterClasses.shrinkToFit(); } OwnPtr<ByteDisjunction> m_body; bool m_ignoreCase; bool m_multiline; // Each BytecodePattern is associated with a RegExp, each RegExp is associated - // with a JSGlobalData. Cache a pointer to out JSGlobalData's m_regExpAllocator. + // with a VM. Cache a pointer to out VM's m_regExpAllocator. BumpPointerAllocator* m_allocator; CharacterClass* newlineCharacterClass; CharacterClass* wordcharCharacterClass; private: - Vector<ByteDisjunction*> m_allParenthesesInfo; - Vector<CharacterClass*> m_userCharacterClasses; + Vector<OwnPtr<ByteDisjunction> > m_allParenthesesInfo; + Vector<OwnPtr<CharacterClass> > m_userCharacterClasses; }; JS_EXPORT_PRIVATE PassOwnPtr<BytecodePattern> byteCompile(YarrPattern&, BumpPointerAllocator*); |