From: echo <1558449520@qq.com> Date: Mon, 4 Sep 2023 16:13:36 +0000 (+0800) Subject: refactor(memory): reduce duplicate 'queue.push' (#1973) X-Git-Tag: v4.2.5~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e6594b6f9a38f7be4f78e71d1e5da7ff5e52260d;p=thirdparty%2Fvuejs%2Frouter.git refactor(memory): reduce duplicate 'queue.push' (#1973) --- diff --git a/packages/router/src/history/memory.ts b/packages/router/src/history/memory.ts index c2ec8194..f8f25a08 100644 --- a/packages/router/src/history/memory.ts +++ b/packages/router/src/history/memory.ts @@ -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(