Skip to content

refactor: Remove usage of float instruction#823

Merged
seanmonstar merged 1 commit intohyperium:masterfrom
AurelienFT:master
Mar 3, 2026
Merged

refactor: Remove usage of float instruction#823
seanmonstar merged 1 commit intohyperium:masterfrom
AurelienFT:master

Conversation

@AurelienFT
Copy link
Contributor

Summary

Replace the floating-point load factor computation in HeaderMap with mathematically equivalent integer arithmetic. This removes the only two f32 usages 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 http crate can't be used in these WASM contexts because of the two f32 operations in HeaderMap'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.

@seanmonstar seanmonstar merged commit d59d939 into hyperium:master Mar 3, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants