Skip to content

Commit

Permalink
codegen: remove unnecessary sorting of keys in ID Maps
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-c committed Dec 10, 2024
1 parent c5863dd commit 2a9365d
Show file tree
Hide file tree
Showing 8 changed files with 1,054 additions and 1,053 deletions.
2 changes: 1 addition & 1 deletion schema_salad/dotnet/util/Loaders/IdMapLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public object Load(in object doc_, in string baseuri, in LoadingOptions loadingO
{
List<object> r = new();
Dictionary<string, object> d = docDict.Cast<dynamic>().ToDictionary(entry => (string)entry.Key, entry => entry.Value);
foreach (string? k in d.Keys.OrderBy(p => p))
foreach (string? k in d.Keys)
{
object val = d[k];
if (val is IDictionary dictionary)
Expand Down
4 changes: 1 addition & 3 deletions schema_salad/java/main_utils/IdMapLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ public T load(
if (doc instanceof Map) {
final Map<String, Object> docMap = (Map<String, Object>) doc;
final List<Object> asList = new ArrayList();
final TreeSet<String> sortedKeys = new TreeSet<String>();
sortedKeys.addAll(docMap.keySet());
for (final String key : sortedKeys) {
for (final String key : docMap.keySet()) {
final Object el = docMap.get(key);
if (el instanceof Map) {
final Map<String, Object> v2 = new HashMap<String, Object>((Map<String, Object>) el);
Expand Down
2 changes: 1 addition & 1 deletion schema_salad/metaschema.py
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,7 @@ def load(
) -> Any:
if isinstance(doc, MutableMapping):
r: list[Any] = []
for k in sorted(doc.keys()):
for k in doc.keys():
val = doc[k]
if isinstance(val, CommentedMap):
v = copy.copy(val)
Expand Down
2 changes: 1 addition & 1 deletion schema_salad/python_codegen_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,7 @@ def load(
) -> Any:
if isinstance(doc, MutableMapping):
r: list[Any] = []
for k in sorted(doc.keys()):
for k in doc.keys():
val = doc[k]
if isinstance(val, CommentedMap):
v = copy.copy(val)
Expand Down
Loading

0 comments on commit 2a9365d

Please sign in to comment.