From 23084519ff92159f916f47903a524220b0e5e6c4 Mon Sep 17 00:00:00 2001 From: Michael Herzog Date: Sat, 11 Nov 2023 10:09:41 +0100 Subject: [PATCH] USDZLoader: Avoid recursive calls of `parseNextLine()`. (#27169) --- examples/jsm/loaders/USDZLoader.js | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/examples/jsm/loaders/USDZLoader.js b/examples/jsm/loaders/USDZLoader.js index 36a87a46f95d23..6532c3c53b0b3c 100644 --- a/examples/jsm/loaders/USDZLoader.js +++ b/examples/jsm/loaders/USDZLoader.js @@ -25,9 +25,7 @@ class USDAParser { const data = {}; const lines = text.split( '\n' ); - const length = lines.length; - let current = 0; let string = null; let target = data; @@ -35,9 +33,7 @@ class USDAParser { // debugger; - function parseNextLine() { - - const line = lines[ current ]; + for ( const line of lines ) { // console.log( line ); @@ -74,7 +70,7 @@ class USDAParser { stack.pop(); - if ( stack.length === 0 ) return; + if ( stack.length === 0 ) continue; target = stack[ stack.length - 1 ]; @@ -100,18 +96,8 @@ class USDAParser { } - current ++; - - if ( current < length ) { - - parseNextLine(); - - } - } - parseNextLine(); - return data; } @@ -640,7 +626,7 @@ class USDZLoader extends Loader { } - } else if ( 'float inputs:clearcoat' in surface ) { + } else if ( 'float inputs:clearcoat' in surface ) { material.clearcoat = parseFloat( surface[ 'float inputs:clearcoat' ] );