Skip to content

Commit 051fbfd

Browse files
authored
NodeMaterialObserver: Avoid usage of Object.keys(). (#33113)
1 parent 0534c39 commit 051fbfd

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/materials/nodes/manager/NodeMaterialObserver.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -393,26 +393,23 @@ class NodeMaterialObserver {
393393
const attributes = geometry.attributes;
394394
const storedAttributes = storedGeometryData.attributes;
395395

396-
const storedAttributeNames = Object.keys( storedAttributes );
397-
const currentAttributeNames = Object.keys( attributes );
398-
399396
if ( storedGeometryData.id !== geometry.id ) {
400397

401398
storedGeometryData.id = geometry.id;
402399
return false;
403400

404401
}
405402

406-
if ( storedAttributeNames.length !== currentAttributeNames.length ) {
403+
// attributes
407404

408-
renderObjectData.geometry.attributes = this.getAttributesData( attributes );
409-
return false;
405+
let currentAttributeCount = 0;
406+
let storedAttributeCount = 0;
410407

411-
}
408+
for ( const _ in attributes ) currentAttributeCount ++; // eslint-disable-line no-unused-vars
412409

413-
// compare each attribute
410+
for ( const name in storedAttributes ) {
414411

415-
for ( const name of storedAttributeNames ) {
412+
storedAttributeCount ++;
416413

417414
const storedAttributeData = storedAttributes[ name ];
418415
const attribute = attributes[ name ];
@@ -435,6 +432,13 @@ class NodeMaterialObserver {
435432

436433
}
437434

435+
if ( storedAttributeCount !== currentAttributeCount ) {
436+
437+
renderObjectData.geometry.attributes = this.getAttributesData( attributes );
438+
return false;
439+
440+
}
441+
438442
// check index
439443

440444
const index = geometry.index;

0 commit comments

Comments
 (0)