Commit 742ae614 authored by Ben Noordhuis's avatar Ben Noordhuis
Browse files

lib,src: port isIPv4() to js

Removes a few lines of C++ code while making `isIPv4()` about 3x faster.
`isIPv6()` and `isIP()` for the IPv6 case stay about the same.

I removed the homegrown `isIPv4()` in lib/dns.js that utilized a lookup
table.  It is in fact a little faster than the new `isIPv4()` function
but:

1. The difference is only measurable at around 10M iterations, and
2. The function is a "probably IPv4" heuristic, not a proper validator.

PR-URL: https://github.com/nodejs/node/pull/18398


Reviewed-By: default avatarAnna Henningsen <anna@addaleax.net>
Reviewed-By: default avatarColin Ihrig <cjihrig@gmail.com>
Reviewed-By: default avatarJames M Snell <jasnell@gmail.com>
Reviewed-By: default avatarJan Krems <jan.krems@gmail.com>
Reviewed-By: default avatarJoyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: default avatarRichard Lau <riclau@uk.ibm.com>
parent 1598ec73
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment