Changeset 3478 in webkit for trunk/JavaScriptCore/kjs/array_object.cpp
- Timestamp:
- Jan 28, 2003, 12:50:56 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/array_object.cpp
r3373 r3478 113 113 unsigned index = propertyName.toULong(&ok); 114 114 if (ok) { 115 if (length <= index) 116 setLength(index + 1, exec); 117 if (index < storageLength) { 118 storage[index] = value.imp(); 119 return; 120 } 115 put(exec, index, value, attr); 116 return; 121 117 } 122 118 … … 126 122 void ArrayInstanceImp::put(ExecState *exec, unsigned index, const Value &value, int attr) 127 123 { 128 if (length <= index) 129 setLength(index + 1, exec); 124 if (index < sparseArrayCutoff && index >= storageLength) { 125 resizeStorage(index + 1); 126 } 127 128 if (index >= length) { 129 length = index + 1; 130 } 131 130 132 if (index < storageLength) { 131 133 storage[index] = value.imp(); … … 133 135 } 134 136 137 assert(index >= sparseArrayCutoff); 135 138 ObjectImp::put(exec, Identifier::from(index), value, attr); 136 139 } … … 214 217 } 215 218 216 217 219 void ArrayInstanceImp::resizeStorage(unsigned newLength) 218 220 { … … 221 223 } 222 224 if (newLength > capacity) { 223 unsigned newCapacity = (newLength * 3 + 1) / 2; 225 unsigned newCapacity; 226 if (newLength > sparseArrayCutoff) { 227 newCapacity = newLength; 228 } else { 229 newCapacity = (newLength * 3 + 1) / 2; 230 if (newCapacity > sparseArrayCutoff) { 231 newCapacity = sparseArrayCutoff; 232 } 233 } 224 234 storage = (ValueImp **)realloc(storage, newCapacity * sizeof (ValueImp *)); 225 235 memset(storage + capacity, 0, sizeof(ValueImp *) * (newCapacity - capacity)); … … 231 241 void ArrayInstanceImp::setLength(unsigned newLength, ExecState *exec) 232 242 { 233 if (newLength <= MAX(sparseArrayCutoff,storageLength) || newLength == length + 1) {243 if (newLength <= storageLength) { 234 244 resizeStorage(newLength); 235 245 }
Note:
See TracChangeset
for help on using the changeset viewer.