Skip to content

Commit

Permalink
array push instead recreating
Browse files Browse the repository at this point in the history
  • Loading branch information
stan-donarise committed Mar 29, 2024
1 parent b8eb9df commit 13a7c98
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
6 changes: 3 additions & 3 deletions plot/cube/cube.view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ namespace $.$$ {
@ $mol_mem
scatters() {

const values: Map< [string/*label*/, number/*json index*/], number/*v*/ > = new Map()
const values: Map< [ label: string, json_index: number ], number/*v*/ > = new Map()

const entries: Map< string/*point label*/, number[]/*json indexes*/> = new Map()

Expand All @@ -154,8 +154,8 @@ namespace $.$$ {
const points = $mpds_visavis_plot_cube_json( json ).payload.points
points.labels.forEach( (label, i)=> {

const prev = entries.get( label ) ?? []
entries.set( label, [ ...prev, index ] )
entries.get( label )?.push( index ) ?? entries.set( label, [ index ] )

values.set( [ label, index ], points.v[i] )

if( !labels.has( label ) ) {
Expand Down
3 changes: 1 addition & 2 deletions plot/matrix/matrix.view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@ namespace $.$$ {
const map = new Map< string, typeof $mpds_visavis_plot_matrix_json_link['Value'][] >()

this.links().forEach( l => {
const prev = map.get( l.cmt ) ?? []
map.set( l.cmt, [ ...prev, l ] )
map.get( l.cmt )?.push( l ) ?? map.set( l.cmt, [ l ] )
} )

return map
Expand Down

0 comments on commit 13a7c98

Please sign in to comment.