File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
Sources/Common/Core/DataArray Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -425,8 +425,23 @@ function vtkDataArray(publicAPI, model) {
425
425
} ;
426
426
427
427
publicAPI . deepCopy = ( other ) => {
428
+ // Retain current dataType and array reference before shallowCopy call.
429
+ const currentType = publicAPI . getDataType ( ) ;
430
+ const currentArray = model . values ;
428
431
publicAPI . shallowCopy ( other ) ;
429
- publicAPI . setData ( other . getData ( ) . slice ( ) ) ;
432
+
433
+ // Avoid array reallocation if size already sufficient
434
+ // and dataTypes match.
435
+ if (
436
+ currentArray ?. length >= other . getNumberOfValues ( ) &&
437
+ currentType === other . getDataType ( )
438
+ ) {
439
+ currentArray . set ( other . getData ( ) ) ;
440
+ model . values = currentArray ;
441
+ publicAPI . dataChange ( ) ;
442
+ } else {
443
+ publicAPI . setData ( other . getData ( ) . slice ( ) ) ;
444
+ }
430
445
} ;
431
446
432
447
publicAPI . interpolateTuple = (
You can’t perform that action at this time.
0 commit comments