@@ -143,16 +143,18 @@ export const createFor = (
143143 }
144144 } else {
145145 const commonLength = Math . min ( oldLength , newLength )
146- const oldKeyToIndexMap = new Map < any , number > ( )
146+ const oldKeyToIndex : [ any , number ] [ ] = new Array ( oldLength )
147147 const pendingNews : [
148148 index : number ,
149149 item : ReturnType < typeof getItem > ,
150150 key : any ,
151- ] [ ] = [ ]
151+ ] [ ] = new Array ( newLength )
152152
153153 let defaultAnchor : Node = parentAnchor
154154 let right = 0
155155 let left = 0
156+ let l1 = 0
157+ let l2 = 0
156158
157159 while ( right < commonLength ) {
158160 const index = newLength - right - 1
@@ -179,23 +181,27 @@ export const createFor = (
179181 if ( oldKey === key ) {
180182 update ( ( newBlocks [ left ] = oldBlock ) , item [ 0 ] )
181183 } else {
182- pendingNews . push ( [ left , item , key ] )
183- oldKeyToIndexMap . set ( oldKey , left )
184+ pendingNews [ l1 ++ ] = [ left , item , key ]
185+ oldKeyToIndex [ l2 ++ ] = [ oldKey , left ]
184186 }
185187 left ++
186188 }
187189
188190 for ( let i = left ; i < oldLength - right ; i ++ ) {
189- oldKeyToIndexMap . set ( oldBlocks [ i ] . key , i )
191+ oldKeyToIndex [ l2 ++ ] = [ oldBlocks [ i ] . key , i ]
190192 }
191193
192194 const prepareLength = Math . min ( newLength - right , commonLength )
193195 for ( let i = left ; i < prepareLength ; i ++ ) {
194196 const item = getItem ( source , i )
195197 const key = getKey . apply ( null , item )
196- pendingNews . push ( [ i , item , key ] )
198+ pendingNews [ l1 ++ ] = [ i , item , key ]
197199 }
198200
201+ pendingNews . length = l1
202+ oldKeyToIndex . length = l2
203+
204+ const oldKeyToIndexMap = new Map ( oldKeyToIndex )
199205 const pendingMounts : [
200206 index : number ,
201207 item : ReturnType < typeof getItem > ,
0 commit comments