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 703d37c
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 7 deletions.
37 changes: 37 additions & 0 deletions map-ordering.cwl
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
cwlVersion: v1.2
class: Workflow
inputs:
09first_input: str
05second_input: int
01third_input: File
steps:
zz_step_one:
run:
class: ExpressionTool
inputs: []
outputs: []
expression: ${return {}; }
requirements:
InlineJavascriptRequirement: {}
in: []
out: []
00_step_two:
out: []
run:
inputs: []
requirements:
InlineJavascriptRequirement: {}
outputs: []
expression: ${return; }
class: ExpressionTool
in: []
outputs:
zz_first_output:
type: File
outputSource: 01third_input
ll_second_output:
type: str
outputSource: 09first_input
aa_third_output:
type: int
outputSource: 09first_input
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
2 changes: 1 addition & 1 deletion schema_salad/typescript/util/loaders/IdMapLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class _IdMapLoader implements Loader {
async load (doc: any, baseuri: string, loadingOptions: LoadingOptions, docRoot?: string): Promise<any> {
if (TypeGuards.isDictionary(doc)) {
const r: any[] = []
for (var k of Object.keys(doc).sort(undefined)) {
for (var k of Object.keys(doc)) {
const val = doc[k]
if (TypeGuards.isDictionary(val)) {
const v2 = Object.assign({}, val)
Expand Down

0 comments on commit 703d37c

Please sign in to comment.