Skip to content

Commit c6f2e12

Browse files
authored
Merge pull request #2599 from Kitware/fix-classhierarchy-impl-usage
Fix classhierarchy impl usage
2 parents 9bcbc64 + 9e88f06 commit c6f2e12

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
/* eslint-disable prefer-rest-params */
22
export default class ClassHierarchy extends Array {
33
push() {
4-
// using a for loop because a filter would trigger the garbage collector
5-
const newArgs = [];
64
for (let i = 0; i < arguments.length; i++) {
75
if (!this.includes(arguments[i])) {
8-
newArgs.push(arguments[i]);
6+
super.push(arguments[i]);
97
}
108
}
119

12-
return super.push(...newArgs);
10+
return this.length;
1311
}
1412
}

Sources/macros.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,11 @@ export function obj(publicAPI = {}, model = {}) {
246246
if (!('classHierarchy' in model)) {
247247
model.classHierarchy = new ClassHierarchy('vtkObject');
248248
} else if (!(model.classHierarchy instanceof ClassHierarchy)) {
249-
model.classHierarchy = ClassHierarchy.from(model.classHierarchy);
249+
const hierarchy = new ClassHierarchy();
250+
for (let i = 0; i < model.classHierarchy.length; i++) {
251+
hierarchy.push(model.classHierarchy[i]);
252+
}
253+
model.classHierarchy = hierarchy;
250254
}
251255

252256
function off(index) {

0 commit comments

Comments
 (0)