Changeset 45545 in webkit for trunk/JavaScriptCore/runtime/RegExp.cpp
- Timestamp:
- Jul 4, 2009, 7:21:30 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/runtime/RegExp.cpp
r44224 r45545 2 2 * Copyright (C) 1999-2001, 2004 Harri Porten ([email protected]) 3 3 * Copyright (c) 2007, 2008 Apple Inc. All rights reserved. 4 * Copyright (C) 2009 Torch Mobile, Inc. 4 5 * 5 6 * This library is free software; you can redistribute it and/or … … 111 112 } 112 113 113 int RegExp::match(const UString& s, int startOffset, OwnArrayPtr<int>* ovector)114 int RegExp::match(const UString& s, int startOffset, Vector<int, 32>* ovector) 114 115 { 115 116 if (startOffset < 0) … … 127 128 #endif 128 129 int offsetVectorSize = (m_numSubpatterns + 1) * 3; // FIXME: should be 2 - but adding temporary fallback to pcre. 129 int* offsetVector = new int [offsetVectorSize]; 130 int* offsetVector; 131 Vector<int, 32> nonReturnedOvector; 132 if (ovector) { 133 ovector->resize(offsetVectorSize); 134 offsetVector = ovector->data(); 135 } else { 136 nonReturnedOvector.resize(offsetVectorSize); 137 offsetVector = nonReturnedOvector.data(); 138 } 139 130 140 ASSERT(offsetVector); 131 141 for (int j = 0; j < offsetVectorSize; ++j) 132 142 offsetVector[j] = -1; 133 143 134 OwnArrayPtr<int> nonReturnedOvector;135 if (!ovector)136 nonReturnedOvector.set(offsetVector);137 else138 ovector->set(offsetVector);139 144 140 145 #if ENABLE(YARR_JIT) … … 178 183 } 179 184 180 int RegExp::match(const UString& s, int startOffset, OwnArrayPtr<int>* ovector)185 int RegExp::match(const UString& s, int startOffset, Vector<int, 32>* ovector) 181 186 { 182 187 if (startOffset < 0) … … 191 196 if (m_wrecFunction) { 192 197 int offsetVectorSize = (m_numSubpatterns + 1) * 2; 193 int* offsetVector = new int [offsetVectorSize]; 198 int* offsetVector; 199 Vector<int, 32> nonReturnedOvector; 200 if (ovector) { 201 ovector->resize(offsetVectorSize); 202 offsetVector = ovector->data(); 203 } else { 204 nonReturnedOvector.resize(offsetVectorSize); 205 offsetVector = nonReturnedOvector.data(); 206 } 194 207 ASSERT(offsetVector); 195 208 for (int j = 0; j < offsetVectorSize; ++j) 196 209 offsetVector[j] = -1; 197 198 OwnArrayPtr<int> nonReturnedOvector;199 if (!ovector)200 nonReturnedOvector.set(offsetVector);201 else202 ovector->set(offsetVector);203 210 204 211 int result = m_wrecFunction(s.data(), startOffset, s.size(), offsetVector); … … 227 234 } else { 228 235 offsetVectorSize = (m_numSubpatterns + 1) * 3; 229 o ffsetVector = new int [offsetVectorSize];230 o vector->set(offsetVector);236 ovector->resize(offsetVectorSize); 237 offsetVector = ovector->data(); 231 238 } 232 239
Note:
See TracChangeset
for help on using the changeset viewer.