Skip to content

Commit

Permalink
Sort JSON output (#315)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Timmmm authored Dec 20, 2024
1 parent 9226b0d commit f4aa35e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions parse.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
import collections

import json
import logging
import pprint
Expand Down Expand Up @@ -43,16 +43,16 @@ def main():
include_pseudo = "-pseudo" in sys.argv[1:]

instr_dict = create_inst_dict(extensions, include_pseudo)
instr_dict = dict(sorted(instr_dict.items()))

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

if "-c" in sys.argv[1:]:
instr_dict_c = create_inst_dict(
extensions, False, include_pseudo_ops=emitted_pseudo_ops
)
instr_dict_c = collections.OrderedDict(sorted(instr_dict_c.items()))
instr_dict_c = dict(sorted(instr_dict_c.items()))
make_c(instr_dict_c)
logging.info("encoding.out.h generated successfully")

Expand Down

0 comments on commit f4aa35e

Please sign in to comment.