rems-project / linksem

Semantic model for aspects of ELF static linking and DWARF debug information
Other
43 stars 7 forks source link

Optimize write_natural_field #14

Open emersion opened 6 years ago

emersion commented 6 years ago

The next perf bottleneck is write_natural_field. I thought byte_sequence was used in memory images, but it turns out this is used instead:

type byte_pattern_element = maybe byte
type byte_pattern = list byte_pattern_element

(* An element might have an address/offset, and it has some contents. *)
type element = <| startpos : maybe natural
                ; length   : maybe natural
                ; contents : byte_pattern
                |>

Is there a reason why we use maybe byte instead of byte here?

Since element is used 140 times in the whole codebase, replacing it with something else is possible but definitely not trivial.