Browse Source

Improve the performance of attribute parsing for .b3dm

The previous implementation would use a lot of string allocations which
would cause the garbage collector to kick in often and that was a major
fit for performance.

This patch fixes the issue by using the built-in TextDecoder class, but
it might break compatibility with old browsers (e.g. Internet Explorer).
Stelios Vitalis 4 years ago
parent
commit
5e9b59c71f
1 changed files with 2 additions and 8 deletions
  1. 2 8
      src/utilities/arrayToString.js

+ 2 - 8
src/utilities/arrayToString.js

@@ -1,12 +1,6 @@
 export function arrayToString( array ) {
 
-	let str = '';
-	for ( let i = 0, l = array.length; i < l; i ++ ) {
-
-		str += String.fromCharCode( array[ i ] );
-
-	}
-
-	return str;
+	const utf8decoder = new TextDecoder();
+	return utf8decoder.decode( array );
 
 }