Skip to content

Commit

Permalink
Use IndexMap in byte_seq_parser macro (#438)
Browse files Browse the repository at this point in the history
This make map iteration deterministic and makes tiny builds
reproducible.

Fixes #437.
  • Loading branch information
osa1 authored Dec 19, 2024
1 parent eaed50d commit 075c0bf
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
- Improve nick matching to avoid highlighting message incorrectly. (#430)
- Fix resetting message color when a color prefix (0x03) is not followed by a
color code. (#434)
- Refactor an internal macro to make tiny builds deterministic, allowing
reproducible builds. (#437)

# 2024/01/01: 0.12.0

Expand Down
29 changes: 26 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/term_input_macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ edition = "2021"
proc-macro = true

[dependencies]
indexmap = "2.7.0"
proc-macro2 = "1.0"
quote = "1.0"
syn = { version = "2.0", features = ["full", "extra-traits"] }
9 changes: 6 additions & 3 deletions crates/term_input_macros/src/tree.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
use crate::syntax::*;

use indexmap::map::IndexMap;
use proc_macro2::TokenStream;
use quote::quote;
use quote::TokenStreamExt;
use std::collections::HashMap;

struct Node {
idx: usize,
value: Option<syn::Expr>,
next: HashMap<u8, Node>,

// Note: `IndexMap` to be able to deterministically iterate the map and generate code
// deterministically, which allows reproducible builds.
next: IndexMap<u8, Node>,
}

impl Node {
fn new(idx: usize) -> Self {
Node {
idx,
value: None,
next: HashMap::new(),
next: IndexMap::new(),
}
}

Expand Down

0 comments on commit 075c0bf

Please sign in to comment.