diff --git a/benchmark/index.mjs b/benchmark/index.mjs index 1898a7a..df606ff 100644 --- a/benchmark/index.mjs +++ b/benchmark/index.mjs @@ -75,6 +75,13 @@ async function bench() { }, s => { s.replace(/replacement/g, 'replacement\nReplacement'); }); + + const size = 1000000; + runWithInstance('overwrite', ['a'.repeat(size)], s => { + for (let i = 1; i < size; i+=2) { + s.overwrite(i, i+1, 'b'); + } + }); } bench(); diff --git a/src/Chunk.js b/src/Chunk.js index 53ce9a5..e15cc6a 100644 --- a/src/Chunk.js +++ b/src/Chunk.js @@ -11,11 +11,16 @@ export default class Chunk { this.storeName = false; this.edited = false; - // we make these non-enumerable, for sanity while debugging - Object.defineProperties(this, { - previous: { writable: true, value: null }, - next: { writable: true, value: null }, - }); + if (DEBUG) { + // we make these non-enumerable, for sanity while debugging + Object.defineProperties(this, { + previous: { writable: true, value: null }, + next: { writable: true, value: null }, + }); + } else { + this.previous = null; + this.next = null; + } } appendLeft(content) {