]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
refactor(memory): reduce duplicate 'queue.push' (#1973)
authorecho <1558449520@qq.com>
Mon, 4 Sep 2023 16:13:36 +0000 (00:13 +0800)
committerGitHub <noreply@github.com>
Mon, 4 Sep 2023 16:13:36 +0000 (18:13 +0200)
packages/router/src/history/memory.ts

index c2ec8194c2be60baca706c2ef1594aad6e84e692..f8f25a08ca0cb477b57236249f6f882ce0507e59 100644 (file)
@@ -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(