Skip to content

Commit f4aa35e

Browse files
authored
Sort JSON output (#315)
If we're sorting the dictionary anyway we may as well output the JSON sorted. Also since Python 3.6 we can just use `dict()` since the insertion order is preserved.
1 parent 9226b0d commit f4aa35e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Diff for: parse.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env python3
2-
import collections
2+
33
import json
44
import logging
55
import pprint
@@ -43,16 +43,16 @@ def main():
4343
include_pseudo = "-pseudo" in sys.argv[1:]
4444

4545
instr_dict = create_inst_dict(extensions, include_pseudo)
46+
instr_dict = dict(sorted(instr_dict.items()))
4647

4748
with open("instr_dict.json", "w", encoding="utf-8") as outfile:
4849
json.dump(add_segmented_vls_insn(instr_dict), outfile, indent=2)
49-
instr_dict = collections.OrderedDict(sorted(instr_dict.items()))
5050

5151
if "-c" in sys.argv[1:]:
5252
instr_dict_c = create_inst_dict(
5353
extensions, False, include_pseudo_ops=emitted_pseudo_ops
5454
)
55-
instr_dict_c = collections.OrderedDict(sorted(instr_dict_c.items()))
55+
instr_dict_c = dict(sorted(instr_dict_c.items()))
5656
make_c(instr_dict_c)
5757
logging.info("encoding.out.h generated successfully")
5858

0 commit comments

Comments
 (0)