diff options
Diffstat (limited to 'src/3rdparty/webkit/JavaScriptCore/runtime/RegExp.cpp')
-rw-r--r-- | src/3rdparty/webkit/JavaScriptCore/runtime/RegExp.cpp | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/RegExp.cpp b/src/3rdparty/webkit/JavaScriptCore/runtime/RegExp.cpp index 857a316..7dd4a8f 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/RegExp.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/RegExp.cpp @@ -1,6 +1,7 @@ /* * Copyright (C) 1999-2001, 2004 Harri Porten (porten@kde.org) * Copyright (c) 2007, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2009 Torch Mobile, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -110,7 +111,7 @@ void RegExp::compile(JSGlobalData* globalData) #endif } -int RegExp::match(const UString& s, int startOffset, OwnArrayPtr<int>* ovector) +int RegExp::match(const UString& s, int startOffset, Vector<int, 32>* ovector) { if (startOffset < 0) startOffset = 0; @@ -126,16 +127,20 @@ int RegExp::match(const UString& s, int startOffset, OwnArrayPtr<int>* ovector) if (m_regExpBytecode) { #endif int offsetVectorSize = (m_numSubpatterns + 1) * 3; // FIXME: should be 2 - but adding temporary fallback to pcre. - int* offsetVector = new int [offsetVectorSize]; + int* offsetVector; + Vector<int, 32> nonReturnedOvector; + if (ovector) { + ovector->resize(offsetVectorSize); + offsetVector = ovector->data(); + } else { + nonReturnedOvector.resize(offsetVectorSize); + offsetVector = nonReturnedOvector.data(); + } + ASSERT(offsetVector); for (int j = 0; j < offsetVectorSize; ++j) offsetVector[j] = -1; - OwnArrayPtr<int> nonReturnedOvector; - if (!ovector) - nonReturnedOvector.set(offsetVector); - else - ovector->set(offsetVector); #if ENABLE(YARR_JIT) int result = Yarr::executeRegex(m_regExpJITCode, s.data(), startOffset, s.size(), offsetVector, offsetVectorSize); @@ -177,7 +182,7 @@ void RegExp::compile(JSGlobalData* globalData) m_regExp = jsRegExpCompile(reinterpret_cast<const UChar*>(m_pattern.data()), m_pattern.size(), ignoreCaseOption, multilineOption, &m_numSubpatterns, &m_constructionError); } -int RegExp::match(const UString& s, int startOffset, OwnArrayPtr<int>* ovector) +int RegExp::match(const UString& s, int startOffset, Vector<int, 32>* ovector) { if (startOffset < 0) startOffset = 0; @@ -190,17 +195,19 @@ int RegExp::match(const UString& s, int startOffset, OwnArrayPtr<int>* ovector) #if ENABLE(WREC) if (m_wrecFunction) { int offsetVectorSize = (m_numSubpatterns + 1) * 2; - int* offsetVector = new int [offsetVectorSize]; + int* offsetVector; + Vector<int, 32> nonReturnedOvector; + if (ovector) { + ovector->resize(offsetVectorSize); + offsetVector = ovector->data(); + } else { + nonReturnedOvector.resize(offsetVectorSize); + offsetVector = nonReturnedOvector.data(); + } ASSERT(offsetVector); for (int j = 0; j < offsetVectorSize; ++j) offsetVector[j] = -1; - OwnArrayPtr<int> nonReturnedOvector; - if (!ovector) - nonReturnedOvector.set(offsetVector); - else - ovector->set(offsetVector); - int result = m_wrecFunction(s.data(), startOffset, s.size(), offsetVector); if (result < 0) { @@ -226,8 +233,8 @@ int RegExp::match(const UString& s, int startOffset, OwnArrayPtr<int>* ovector) offsetVector = fixedSizeOffsetVector; } else { offsetVectorSize = (m_numSubpatterns + 1) * 3; - offsetVector = new int [offsetVectorSize]; - ovector->set(offsetVector); + ovector->resize(offsetVectorSize); + offsetVector = ovector->data(); } int numMatches = jsRegExpExecute(m_regExp, reinterpret_cast<const UChar*>(s.data()), s.size(), startOffset, offsetVector, offsetVectorSize); |