Skip to content

Commit

Permalink
Truncate old value when replacing an element
Browse files Browse the repository at this point in the history
  • Loading branch information
mmomtchev committed Aug 22, 2020
1 parent 01244ba commit d56af30
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion index.es.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,10 @@ class SharedMap {
this.stats.collisions++;
/* Replacing existing key */
if (this._match(key, pos)) {
for (let i = 0; i < value.length; i++)
let i;
for (i = 0; i < value.length; i++)
this.valuesData[pos * this.meta[META.objSize] + i] = value.charCodeAt(i);
this.valuesData[pos * this.meta[META.objSize] + i] = 0;
exclusive || this._unlockLine(slidingLock);
return;
}
Expand Down
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,10 @@ export default class SharedMap {
this.stats.collisions++;
/* Replacing existing key */
if (this._match(key, pos)) {
for (let i = 0; i < value.length; i++)
let i;
for (i = 0; i < value.length; i++)
this.valuesData[pos * this.meta[META.objSize] + i] = value.charCodeAt(i);
this.valuesData[pos * this.meta[META.objSize] + i] = 0;
exclusive || this._unlockLine(slidingLock);
return;
}
Expand Down
4 changes: 3 additions & 1 deletion index.umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,10 @@
this.stats.collisions++;
/* Replacing existing key */
if (this._match(key, pos)) {
for (let i = 0; i < value.length; i++)
let i;
for (i = 0; i < value.length; i++)
this.valuesData[pos * this.meta[META.objSize] + i] = value.charCodeAt(i);
this.valuesData[pos * this.meta[META.objSize] + i] = 0;
exclusive || this._unlockLine(slidingLock);
return;
}
Expand Down

0 comments on commit d56af30

Please sign in to comment.