Skip to content

Commit 0343988

Browse files
monkeycfPanJiaChen
authored andcommitted
perf[tagsView]: pref DEL_CACHED_VIEW and DEL_OTHERS_CACHED_VIEWS function (#2626)
1 parent 9c723c6 commit 0343988

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

src/store/modules/tagsView.js

+4-14
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,8 @@ const mutations = {
2828
}
2929
},
3030
DEL_CACHED_VIEW: (state, view) => {
31-
for (const i of state.cachedViews) {
32-
if (i === view.name) {
33-
const index = state.cachedViews.indexOf(i)
34-
state.cachedViews.splice(index, 1)
35-
break
36-
}
37-
}
31+
const index = state.cachedViews.indexOf(view.name)
32+
index > -1 && state.cachedViews.splice(index, 1)
3833
},
3934

4035
DEL_OTHERS_VISITED_VIEWS: (state, view) => {
@@ -43,13 +38,8 @@ const mutations = {
4338
})
4439
},
4540
DEL_OTHERS_CACHED_VIEWS: (state, view) => {
46-
for (const i of state.cachedViews) {
47-
if (i === view.name) {
48-
const index = state.cachedViews.indexOf(i)
49-
state.cachedViews = state.cachedViews.slice(index, index + 1)
50-
break
51-
}
52-
}
41+
const index = state.cachedViews.indexOf(view.name)
42+
index > -1 && (state.cachedViews = state.cachedViews.slice(index, index + 1))
5343
},
5444

5545
DEL_ALL_VISITED_VIEWS: state => {

0 commit comments

Comments
 (0)