Skip to content

Commit

Permalink
optimisation - remove empty chunks when overwriting
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris committed Dec 1, 2016
1 parent 5c24a58 commit c508616
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

1 comment on commit c508616

@eventualbuddha
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something about this seems to be causing decaffeinate to fail: decaffeinate/decaffeinate#581. Maybe this wasn't as safe as you thought for a patch version bump?

Please sign in to comment.