Skip to content

Commit

Permalink
perf: small code changes to maximize performance
Browse files Browse the repository at this point in the history
  • Loading branch information
Akryum committed Oct 18, 2022
1 parent 95b934a commit 3b4dbf3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ export default {
const result = []
const { items, keyField, simpleArray } = this
const sizes = this.vscrollData.sizes
for (let i = 0; i < items.length; i++) {
const l = items.length
for (let i = 0; i < l; i++) {
const item = items[i]
const id = simpleArray ? i : item[keyField]
let size = sizes[id]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export default {
},
updateWatchData () {
if (this.watchData) {
if (this.watchData && !this.vscrollResizeObserver) {
this.$_watchData = this.$watch('item', () => {
this.onDataUpdate()
}, {
Expand Down Expand Up @@ -188,7 +188,7 @@ export default {
},
applySize (width, height) {
const size = Math.round(this.vscrollParent.direction === 'vertical' ? height : width)
const size = ~~(this.vscrollParent.direction === 'vertical' ? height : width)
if (size && this.size !== size) {
if (this.vscrollParent.$_undefinedMap[this.id]) {
this.vscrollParent.$_undefinedSizes--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -500,9 +500,7 @@ export default {
if (view.nr.used) {
// Update view item index
if (checkItem) {
view.nr.index = items.findIndex(
item => keyField ? item[keyField] === view.item[keyField] : item === view.item,
)
view.nr.index = items.indexOf(view.item)
}
// Check if index is still in visible range
Expand Down

0 comments on commit 3b4dbf3

Please sign in to comment.