Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 /* | 1 /* |
2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, |
3 * Copyright (C) 2006-2014 Eyeo GmbH | 3 * Copyright (C) 2006-2014 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
157 } | 157 } |
158 else | 158 else |
159 { | 159 { |
160 // This array is too large, it needs an individual buffer | 160 // This array is too large, it needs an individual buffer |
161 bufferIndex = addBuffer(referenceLength * newSize, buffers, viewTypes, views); | 161 bufferIndex = addBuffer(referenceLength * newSize, buffers, viewTypes, views); |
162 } | 162 } |
163 | 163 |
164 if (size > 0) | 164 if (size > 0) |
165 { | 165 { |
166 let copyBytes = length * referenceLength; | 166 let copyBytes = length * referenceLength; |
167 let src = Uint8Array(buffers[this.arrayBufferIndex], this.arrayByteOff set, copyBytes); | 167 let src = new Uint8Array(buffers[this.arrayBufferIndex], this.arrayByt eOffset, copyBytes); |
168 let dst = Uint8Array(buffers[bufferIndex], byteOffset, copyBytes); | 168 let dst = new Uint8Array(buffers[bufferIndex], byteOffset, copyBytes); |
169 dst.set(src); | 169 dst.set(src); |
170 } | 170 } |
171 | 171 |
172 this.arrayBufferIndex = bufferIndex; | 172 this.arrayBufferIndex = bufferIndex; |
173 this.arrayByteOffset = byteOffset; | 173 this.arrayByteOffset = byteOffset; |
174 } | 174 } |
175 else | 175 else |
176 this.arrayBufferIndex = -1; | 176 this.arrayBufferIndex = -1; |
177 | 177 |
178 if (size > 0) | 178 if (size > 0) |
(...skipping 30 matching lines...) Expand all Loading... | |
209 let result = this.get(length - 1); | 209 let result = this.get(length - 1); |
210 this.length = this.length - 1; | 210 this.length = this.length - 1; |
211 return result; | 211 return result; |
212 } | 212 } |
213 | 213 |
214 function splice(index, count) | 214 function splice(index, count) |
215 { | 215 { |
216 index = index | 0; | 216 index = index | 0; |
217 count = count | 0; | 217 count = count | 0; |
218 let length = this.length | 0; | 218 let length = this.length | 0; |
219 if (index < 0) | 219 if (index < 0) |
René Jeschke
2014/05/19 08:35:53
What about the negative indexing one can use on 's
Wladimir Palant
2014/05/19 15:22:02
You are right, I wasn't aware that splice supporte
| |
220 index = 0; | 220 { |
221 index += length; | |
222 if (index < 0) | |
223 index = 0; | |
224 } | |
221 if (index > length) | 225 if (index > length) |
222 index = length; | 226 index = length; |
223 if (index + count > length) | 227 if (index + count > length) |
224 count = length - index; | 228 count = length - index; |
225 | 229 |
226 let newCount = (arguments.length | 0) - 2; | 230 let newCount = (arguments.length | 0) - 2; |
227 let diff = newCount - count; | 231 let diff = newCount - count; |
228 let newLength = length + diff; | 232 let newLength = length + diff; |
229 if (diff > 0) | 233 if (diff > 0) |
230 { | 234 { |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
337 meta.watch = {}; | 341 meta.watch = {}; |
338 | 342 |
339 meta.watch.length = createLengthWatcher(elementType, elementSetter); | 343 meta.watch.length = createLengthWatcher(elementType, elementSetter); |
340 meta.watch.size = createSizeWatcher(elementType, minElements, bufferSize, buff ers, viewTypes, views, firstFree); | 344 meta.watch.size = createSizeWatcher(elementType, minElements, bufferSize, buff ers, viewTypes, views, firstFree); |
341 | 345 |
342 let {ObjectBase} = require("typedObjects/objectTypes"); | 346 let {ObjectBase} = require("typedObjects/objectTypes"); |
343 return ObjectBase.extend(typeDescriptor, meta); | 347 return ObjectBase.extend(typeDescriptor, meta); |
344 } | 348 } |
345 | 349 |
346 exports.createArrayType = createArrayType; | 350 exports.createArrayType = createArrayType; |
LEFT | RIGHT |