refactor: Remove usage of float instruction#823
Merged
seanmonstar merged 1 commit intohyperium:masterfrom Mar 3, 2026
Merged
Conversation
seanmonstar
reviewed
Mar 3, 2026
seanmonstar
approved these changes
Mar 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replace the floating-point load factor computation in
HeaderMapwith mathematically equivalent integer arithmetic. This removes the only twof32usages in the entire crate, making it compatible with WebAssembly environments that forbid floating-point instructions.Motivation
Several WebAssembly runtimes prohibit IEEE 754 floating-point instructions in guest modules.
The
httpcrate can't be used in these WASM contexts because of the twof32operations inHeaderMap's danger-state logic make it impossible to use in these environments without forking.Changes
In
src/header/map.rs:The transformation is exact: a / b >= 0.2 is equivalent to a * 5 >= b for non-negative integers (which len() always returns), with no precision loss since the original threshold is exactly representable as 1/5.