summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2018-01-26 18:39:10 +0100
committerBen Noordhuis <info@bnoordhuis.nl>2018-01-29 14:45:06 +0100
commit742ae6141c164a90442c363599ea0356ed250570 (patch)
treeeb154676811ae6c7529e77b4f0d8d136e080df79 /src
parent1598ec73dff10631847b7b7f31a661ac3efb8e7d (diff)
downloadandroid-node-v8-742ae6141c164a90442c363599ea0356ed250570.tar.gz
android-node-v8-742ae6141c164a90442c363599ea0356ed250570.tar.bz2
android-node-v8-742ae6141c164a90442c363599ea0356ed250570.zip
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: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jan Krems <jan.krems@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Diffstat (limited to 'src')
-rw-r--r--src/cares_wrap.cc12
1 files changed, 0 insertions, 12 deletions
diff --git a/src/cares_wrap.cc b/src/cares_wrap.cc
index 165a8cda20..191e3c92dc 100644
--- a/src/cares_wrap.cc
+++ b/src/cares_wrap.cc
@@ -1886,16 +1886,6 @@ int ParseIP(const char* ip, ParseIPResult* result = nullptr) {
return 0;
}
-void IsIP(const FunctionCallbackInfo<Value>& args) {
- node::Utf8Value ip(args.GetIsolate(), args[0]);
- args.GetReturnValue().Set(ParseIP(*ip));
-}
-
-void IsIPv4(const FunctionCallbackInfo<Value>& args) {
- node::Utf8Value ip(args.GetIsolate(), args[0]);
- args.GetReturnValue().Set(4 == ParseIP(*ip));
-}
-
void IsIPv6(const FunctionCallbackInfo<Value>& args) {
node::Utf8Value ip(args.GetIsolate(), args[0]);
args.GetReturnValue().Set(6 == ParseIP(*ip));
@@ -2138,8 +2128,6 @@ void Initialize(Local<Object> target,
env->SetMethod(target, "getaddrinfo", GetAddrInfo);
env->SetMethod(target, "getnameinfo", GetNameInfo);
- env->SetMethod(target, "isIP", IsIP);
- env->SetMethod(target, "isIPv4", IsIPv4);
env->SetMethod(target, "isIPv6", IsIPv6);
env->SetMethod(target, "canonicalizeIP", CanonicalizeIP);