Explorar el Código

Internal: Further improved performance by cheaper type checks.

The isPlainObject method is pretty slow, and given that elements are created intensively, reducing cost of this brings notable gains.
Marek Lewandowski hace 6 años
padre
commit
531025cf42
Se han modificado 1 ficheros con 3 adiciones y 3 borrados
  1. 3 3
      packages/ckeditor5-engine/src/view/element.js

+ 3 - 3
packages/ckeditor5-engine/src/view/element.js

@@ -859,10 +859,10 @@ export default class Element extends Node {
 // @param {Object|Map} attrs Attributes to parse.
 // @returns {Map} Parsed attributes.
 function parseAttributes( attrs ) {
-	if ( isPlainObject( attrs ) ) {
-		attrs = objectToMap( attrs );
-	} else {
+	if ( attrs instanceof Map ) {
 		attrs = new Map( attrs );
+	} else {
+		attrs = objectToMap( attrs );
 	}
 
 	for ( const [ key, value ] of attrs ) {