Parsing IP addresses quickly (portably, without SIMD magic)

Fast IPv4 parser lands; commenters shout 'Where’s IPv6?' and roast AI-written code

TLDR: A developer shared a fast, portable way to parse IPv4 addresses using standard C++ tools, with a faster library option. Commenters pushed back: it’s 2025—add IPv6, and watch out for zero-padding that ruins predictable speed; the community split between raw speed fans and standards-first purists.

A developer dropped a speedy, portable way to read those familiar “192.168.0.1” addresses—no fancy hardware tricks—after first asking an AI to write a parser and then polishing it with an “unrolled” version and a cleaner switch to C++’s standard number reader, std::from_chars. There’s even a nod to the community-favorite fast_float, which just got a boost for tiny numbers. The code is neat, the goal is speed, and the vibe is: let’s make this snappy.

Then the comments happened. The loudest cry: “It’s 2025—IPv4-only is a snooze.” User traceroute66 wanted dual‑stack (support both IPv4 and the newer IPv6 with colons and brackets), and wasn’t shy about it. Meanwhile, commandersaki highlighted a subtle trap in skeeto’s version, warning that unlimited zero-padding makes parsing time unpredictable—cue the constant-time police. Their fix? Count digits, even if it “yuckies” the code.

The threads turned into a reality show: speed chasers vs. standards sticklers. Jokes flew about “dot detectives” checking every octet and the “192.168 gang” vs. the “bracket squad.” Some praised the clean std::from_chars route, others rolled eyes at the AI assist. The final chorus: cool parser, but do IPv6 next—and please, no infinite zeros.

Key Points

  • The article presents fast, portable IPv4 parsing in C++ without using SIMD.
  • A manual parser validates digits, range (0–255), leading zeros, dot separators, and constructs a 32-bit result.
  • An unrolled implementation assumes one to three digits per octet to reduce overhead and improve speed.
  • A concise approach uses std::from_chars to parse each octet as an 8-bit value and simplify logic.
  • The fast_float library’s latest version improves 8-bit integer parsing, credited to Shikhar Soni with a fix by Pavel Novik.

Hottest takes

“It’s 2025—IPv4-only doesn’t deserve my time” — traceroute66
“Unbounded zero padding = not constant time” — commandersaki
Made with <3 by @siedrix and @shesho from CDMX. Powered by Forge&Hive.