Skip to content

Commit b680b06

Browse files
committed
Case-insensitive name matching and indexing fix
Remove struct concatenation, not guaranteed that the types vocab is homogeneous
1 parent efd54e2 commit b680b06

2 files changed

Lines changed: 5 additions & 6 deletions

File tree

code/internal/+openminds/+internal/+vocab/getSchemaColor.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
end
88

99
C = struct2cell(typesVocab);
10-
S = [C{:}];
1110

12-
isMatch = strcmp({S.name}, schemaName);
11+
allNames = cellfun(@(c) string(c.name), C);
12+
isMatch = strcmpi(allNames, schemaName);
1313

1414
if any(isMatch)
15-
color = S(isMatch).color;
15+
color = C{isMatch}.color;
1616
else
1717
error('No schemas matched name "%s"', schemaName)
1818
end

code/internal/+openminds/+internal/+vocab/getSchemaLabelFromName.m

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,15 @@
1010
end
1111

1212
C = struct2cell(typesVocab);
13-
S = [C{:}];
1413

15-
allNames = {S.name};
14+
allNames = cellfun(@(c) string(c.name), C);
1615
isMatch = strcmpi(allNames, schemaName);
1716

1817
if ~any(isMatch)
1918
throwNoMatchingSchemaException(schemaName);
2019
end
2120

22-
S = S(isMatch);
21+
S = C{isMatch};
2322
schemaLabel = string( S(1).label );
2423

2524
if isscalar(S)

0 commit comments

Comments
 (0)