File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1292,10 +1292,9 @@ class Fuse {
12921292 }
12931293 }
12941294
1295- // Remove from docs in reverse to preserve indices
1296- for ( let i = indicesToRemove . length - 1 ; i >= 0 ; i -= 1 ) {
1297- this . _docs . splice ( indicesToRemove [ i ] , 1 ) ;
1298- }
1295+ // Filter docs in a single pass instead of reverse-splicing
1296+ const toRemove = new Set ( indicesToRemove ) ;
1297+ this . _docs = this . _docs . filter ( ( _ , i ) => ! toRemove . has ( i ) ) ;
12991298 this . _myIndex . removeAll ( indicesToRemove ) ;
13001299 }
13011300 return results ;
Load diff Large diffs are not rendered by default.
Load diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change @@ -1290,10 +1290,9 @@ class Fuse {
12901290 }
12911291 }
12921292
1293- // Remove from docs in reverse to preserve indices
1294- for ( let i = indicesToRemove . length - 1 ; i >= 0 ; i -= 1 ) {
1295- this . _docs . splice ( indicesToRemove [ i ] , 1 ) ;
1296- }
1293+ // Filter docs in a single pass instead of reverse-splicing
1294+ const toRemove = new Set ( indicesToRemove ) ;
1295+ this . _docs = this . _docs . filter ( ( _ , i ) => ! toRemove . has ( i ) ) ;
12971296 this . _myIndex . removeAll ( indicesToRemove ) ;
12981297 }
12991298 return results ;
Original file line number Diff line number Diff line change @@ -1683,10 +1683,9 @@ class Fuse {
16831683 }
16841684 }
16851685
1686- // Remove from docs in reverse to preserve indices
1687- for ( let i = indicesToRemove . length - 1 ; i >= 0 ; i -= 1 ) {
1688- this . _docs . splice ( indicesToRemove [ i ] , 1 ) ;
1689- }
1686+ // Filter docs in a single pass instead of reverse-splicing
1687+ const toRemove = new Set ( indicesToRemove ) ;
1688+ this . _docs = this . _docs . filter ( ( _ , i ) => ! toRemove . has ( i ) ) ;
16901689 this . _myIndex . removeAll ( indicesToRemove ) ;
16911690 }
16921691 return results ;
Load diff Large diffs are not rendered by default.
Load diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change @@ -1681,10 +1681,9 @@ class Fuse {
16811681 }
16821682 }
16831683
1684- // Remove from docs in reverse to preserve indices
1685- for ( let i = indicesToRemove . length - 1 ; i >= 0 ; i -= 1 ) {
1686- this . _docs . splice ( indicesToRemove [ i ] , 1 ) ;
1687- }
1684+ // Filter docs in a single pass instead of reverse-splicing
1685+ const toRemove = new Set ( indicesToRemove ) ;
1686+ this . _docs = this . _docs . filter ( ( _ , i ) => ! toRemove . has ( i ) ) ;
16881687 this . _myIndex . removeAll ( indicesToRemove ) ;
16891688 }
16901689 return results ;
Load diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change @@ -1665,10 +1665,9 @@ class Fuse {
16651665 }
16661666 }
16671667
1668- // Remove from docs in reverse to preserve indices
1669- for ( let i = indicesToRemove . length - 1 ; i >= 0 ; i -= 1 ) {
1670- this . _docs . splice ( indicesToRemove [ i ] , 1 ) ;
1671- }
1668+ // Filter docs in a single pass instead of reverse-splicing
1669+ const toRemove = new Set ( indicesToRemove ) ;
1670+ this . _docs = this . _docs . filter ( ( _ , i ) => ! toRemove . has ( i ) ) ;
16721671 this . _myIndex . removeAll ( indicesToRemove ) ;
16731672 }
16741673 return results ;
You can’t perform that action at this time.
0 commit comments