Skip to content

Commit d56af30

Browse files
committed
Truncate old value when replacing an element
1 parent 01244ba commit d56af30

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

index.es.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,10 @@ class SharedMap {
378378
this.stats.collisions++;
379379
/* Replacing existing key */
380380
if (this._match(key, pos)) {
381-
for (let i = 0; i < value.length; i++)
381+
let i;
382+
for (i = 0; i < value.length; i++)
382383
this.valuesData[pos * this.meta[META.objSize] + i] = value.charCodeAt(i);
384+
this.valuesData[pos * this.meta[META.objSize] + i] = 0;
383385
exclusive || this._unlockLine(slidingLock);
384386
return;
385387
}

index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,8 +379,10 @@ export default class SharedMap {
379379
this.stats.collisions++;
380380
/* Replacing existing key */
381381
if (this._match(key, pos)) {
382-
for (let i = 0; i < value.length; i++)
382+
let i;
383+
for (i = 0; i < value.length; i++)
383384
this.valuesData[pos * this.meta[META.objSize] + i] = value.charCodeAt(i);
385+
this.valuesData[pos * this.meta[META.objSize] + i] = 0;
384386
exclusive || this._unlockLine(slidingLock);
385387
return;
386388
}

index.umd.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,8 +384,10 @@
384384
this.stats.collisions++;
385385
/* Replacing existing key */
386386
if (this._match(key, pos)) {
387-
for (let i = 0; i < value.length; i++)
387+
let i;
388+
for (i = 0; i < value.length; i++)
388389
this.valuesData[pos * this.meta[META.objSize] + i] = value.charCodeAt(i);
390+
this.valuesData[pos * this.meta[META.objSize] + i] = 0;
389391
exclusive || this._unlockLine(slidingLock);
390392
return;
391393
}

0 commit comments

Comments
 (0)