Skip to content

Commit

Permalink
refactor(memory): reduce duplicate 'queue.push' (#1973)
Browse files Browse the repository at this point in the history
  • Loading branch information
leedawn authored Sep 4, 2023
1 parent a70a6f5 commit e6594b6
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions packages/router/src/history/memory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,11 @@ export function createMemoryHistory(base: string = ''): RouterHistory {

function setLocation(location: HistoryLocation) {
position++
if (position === queue.length) {
// we are at the end, we can simply append a new entry
queue.push(location)
} else {
if (position !== queue.length) {
// we are in the middle, we remove everything from here in the queue
queue.splice(position)
queue.push(location)
}
queue.push(location)
}

function triggerListeners(
Expand Down

0 comments on commit e6594b6

Please sign in to comment.