Skip to content

Commit

Permalink
Merge pull request #113 from Rich-Harris/remove-empty-chunks
Browse files Browse the repository at this point in the history
optimisation - remove empty chunks when overwriting
  • Loading branch information
Rich-Harris committed Dec 1, 2016
2 parents 5c24a58 + c508616 commit 07ec268
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/MagicString.js
Expand Up @@ -330,15 +330,15 @@ MagicString.prototype = {
if ( first ) {
first.edit( content, storeName );

if ( first !== last ) {
let chunk = first.next;
while ( chunk !== last ) {
chunk.edit( '', false );
chunk = chunk.next;
}

chunk.edit( '', false );
if ( last ) {
first.next = last.next;
} else {
first.next = null;
this.lastChunk = first;
}

first.original = this.original.slice( start, end );
first.end = end;
}

else {
Expand Down

0 comments on commit 07ec268

Please sign in to comment.