Skip to content

Commit e6594b6

Browse files
authored
refactor(memory): reduce duplicate 'queue.push' (#1973)
1 parent a70a6f5 commit e6594b6

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

packages/router/src/history/memory.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,11 @@ export function createMemoryHistory(base: string = ''): RouterHistory {
2626

2727
function setLocation(location: HistoryLocation) {
2828
position++
29-
if (position === queue.length) {
30-
// we are at the end, we can simply append a new entry
31-
queue.push(location)
32-
} else {
29+
if (position !== queue.length) {
3330
// we are in the middle, we remove everything from here in the queue
3431
queue.splice(position)
35-
queue.push(location)
3632
}
33+
queue.push(location)
3734
}
3835

3936
function triggerListeners(

0 commit comments

Comments
 (0)