@@ -433,41 +433,45 @@ export class PivotUtil {
433433 const recordsKey = pivotKeys . records ;
434434 const childKey = pivotKeys . children ;
435435 const childCollection = val [ childKey ] ;
436- if ( Array . isArray ( hierarchy . get ( val . value ) [ childKey ] ) ) {
437- hierarchy . get ( val . value ) [ childKey ] = new Map < string , any > ( ) ;
436+ const hierarchyValue = hierarchy . get ( val . value ) ;
437+ if ( Array . isArray ( hierarchyValue [ childKey ] ) ) {
438+ hierarchyValue [ childKey ] = new Map < string , any > ( ) ;
438439 }
439440 if ( ! childCollection || childCollection . size === 0 ) {
440- const dim = hierarchy . get ( val . value ) . dimension ;
441+ const dim = hierarchyValue . dimension ;
441442 const isValid = this . extractValueFromDimension ( dim , rec ) === val . value ;
442443 if ( isValid ) {
443- if ( hierarchy . get ( val . value ) [ recordsKey ] ) {
444- hierarchy . get ( val . value ) [ recordsKey ] . push ( rec ) ;
444+ if ( hierarchyValue [ recordsKey ] ) {
445+ hierarchyValue [ recordsKey ] . push ( rec ) ;
445446 } else {
446- hierarchy . get ( val . value ) [ recordsKey ] = [ rec ] ;
447+ hierarchyValue [ recordsKey ] = [ rec ] ;
447448 }
448449 }
449450 } else {
451+ const hierarchyChild = hierarchyValue [ childKey ] ;
450452 for ( const [ key , child ] of childCollection ) {
451- if ( ! hierarchy . get ( val . value ) [ childKey ] . get ( child . value ) ) {
452- hierarchy . get ( val . value ) [ childKey ] . set ( child . value , child ) ;
453+ let hierarchyChildValue = hierarchyChild . get ( child . value ) ;
454+ if ( ! hierarchyChildValue ) {
455+ hierarchyChild . set ( child . value , child ) ;
456+ hierarchyChildValue = child ;
453457 }
454458
455- if ( hierarchy . get ( val . value ) [ childKey ] . get ( child . value ) [ recordsKey ] ) {
459+ if ( hierarchyChildValue [ recordsKey ] ) {
456460 const copy = Object . assign ( { } , rec ) ;
457461 if ( rec [ recordsKey ] ) {
458462 // not all nested children are valid
459- const nestedValue = hierarchy . get ( val . value ) [ childKey ] . get ( child . value ) . value ;
460- const dimension = hierarchy . get ( val . value ) [ childKey ] . get ( child . value ) . dimension ;
463+ const nestedValue = hierarchyChildValue . value ;
464+ const dimension = hierarchyChildValue . dimension ;
461465 const validRecs = rec [ recordsKey ] . filter ( x => this . extractValueFromDimension ( dimension , x ) === nestedValue ) ;
462466 copy [ recordsKey ] = validRecs ;
463467 }
464- hierarchy . get ( val . value ) [ childKey ] . get ( child . value ) [ recordsKey ] . push ( copy ) ;
468+ hierarchyChildValue [ recordsKey ] . push ( copy ) ;
465469 } else {
466- hierarchy . get ( val . value ) [ childKey ] . get ( child . value ) [ recordsKey ] = [ rec ] ;
470+ hierarchyChildValue [ recordsKey ] = [ rec ] ;
467471 }
468472
469473 if ( child [ childKey ] && child [ childKey ] . size > 0 ) {
470- this . applyHierarchyChildren ( hierarchy . get ( val . value ) [ childKey ] , child , rec , pivotKeys ) ;
474+ this . applyHierarchyChildren ( hierarchyChild , child , rec , pivotKeys ) ;
471475 }
472476 }
473477 }
0 commit comments