Changeset 2846 in webkit for trunk/JavaScriptCore/kjs/array_object.cpp
- Timestamp:
- Nov 23, 2002, 11:49:26 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/array_object.cpp
r2843 r2846 105 105 { 106 106 if (propertyName == lengthPropertyName) { 107 setLength(value.toUInt32(exec) );107 setLength(value.toUInt32(exec), exec); 108 108 return; 109 109 } … … 113 113 if (ok) { 114 114 if (length <= index) 115 setLength(index + 1 );115 setLength(index + 1, exec); 116 116 if (index < storageLength) { 117 117 storage[index] = value.imp(); … … 126 126 { 127 127 if (length <= index) 128 setLength(index + 1 );128 setLength(index + 1, exec); 129 129 if (index < storageLength) { 130 130 storage[index] = value.imp(); … … 172 172 173 173 bool ok; 174 u nsigned index = propertyName.toULong(&ok);174 uint32_t index = propertyName.toUInt32(&ok); 175 175 if (ok) { 176 176 if (index >= length) … … 197 197 } 198 198 199 void ArrayInstanceImp::setLength(unsigned newLength) 200 { 201 if (newLength <= sparseArrayCutoff || newLength == length + 1) { 199 void ArrayInstanceImp::resizeStorage(unsigned newLength) 200 { 202 201 if (newLength < storageLength) { 203 202 memset(storage + newLength, 0, sizeof(ValueImp *) * (storageLength - newLength)); … … 210 209 } 211 210 storageLength = newLength; 212 } 213 214 // FIXME: Need to remove items from the property map when making a sparse 215 // list shorter. 211 } 212 213 void ArrayInstanceImp::setLength(unsigned newLength, ExecState *exec) 214 { 215 if (newLength <= MAX(sparseArrayCutoff,storageLength) || newLength == length + 1) { 216 resizeStorage(newLength); 217 } 218 219 if (newLength < length) { 220 ReferenceList sparseProperties; 221 222 _prop.addSparseArrayPropertiesToReferenceList(sparseProperties, Object(this)); 223 224 ReferenceListIterator it = sparseProperties.begin(); 225 while (it != sparseProperties.end()) { 226 Reference ref = it++; 227 bool ok; 228 if (ref.getPropertyName(exec).toULong(&ok) > newLength) { 229 ref.deleteValue(exec); 230 } 231 } 232 } 216 233 217 234 length = newLength; … … 239 256 void ArrayInstanceImp::sort(ExecState *exec) 240 257 { 241 int lengthNotIncludingUndefined = pushUndefinedObjectsToEnd( );258 int lengthNotIncludingUndefined = pushUndefinedObjectsToEnd(exec); 242 259 243 260 execForCompareByStringForQSort = exec; … … 277 294 void ArrayInstanceImp::sort(ExecState *exec, Object &compareFunction) 278 295 { 279 int lengthNotIncludingUndefined = pushUndefinedObjectsToEnd( );296 int lengthNotIncludingUndefined = pushUndefinedObjectsToEnd(exec); 280 297 281 298 CompareWithCompareFunctionArguments args(exec, compareFunction.imp()); … … 285 302 } 286 303 287 unsigned ArrayInstanceImp::pushUndefinedObjectsToEnd( )304 unsigned ArrayInstanceImp::pushUndefinedObjectsToEnd(ExecState *exec) 288 305 { 289 306 ValueImp *undefined = UndefinedImp::staticUndefined; … … 300 317 } 301 318 302 // FIXME: Get sparse items down here. 303 304 if (o != storageLength) 319 ReferenceList sparseProperties; 320 _prop.addSparseArrayPropertiesToReferenceList(sparseProperties, Object(this)); 321 unsigned newLength = o + sparseProperties.length(); 322 323 if (newLength > storageLength) { 324 resizeStorage(newLength); 325 } 326 327 ReferenceListIterator it = sparseProperties.begin(); 328 while (it != sparseProperties.end()) { 329 Reference ref = it++; 330 storage[o] = ref.getValue(exec).imp(); 331 ObjectImp::deleteProperty(exec, ref.getPropertyName(exec)); 332 o++; 333 } 334 335 if (newLength != storageLength) 305 336 memset(storage + o, 0, sizeof(ValueImp *) * (storageLength - o)); 306 337
Note:
See TracChangeset
for help on using the changeset viewer.