From b02d4780ab4fa2bbfd0612db5a3b9e822db1e32f Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Tue, 22 Oct 2024 02:12:23 -0700 Subject: [PATCH] fix: remove to_string override for int64_t --- src/module.cc | 6 +++--- src/observer.cc | 2 +- src/proxy.cc | 2 +- src/util/arguments.h | 5 ++--- src/util/to_string.h | 21 --------------------- 5 files changed, 7 insertions(+), 29 deletions(-) delete mode 100644 src/util/to_string.h diff --git a/src/module.cc b/src/module.cc index ee4ceeec..ff939feb 100644 --- a/src/module.cc +++ b/src/module.cc @@ -8,7 +8,6 @@ #include "./socket.h" #include "./zmq_inc.h" #include "util/error.h" -#include "util/to_string.h" namespace zmq { static inline Napi::String Version(const Napi::Env& env) { @@ -17,8 +16,9 @@ static inline Napi::String Version(const Napi::Env& env) { int32_t patch = 0; zmq_version(&major, &minor, &patch); - return Napi::String::New( - env, to_string(major) + "." + to_string(minor) + "." + to_string(patch)); + return Napi::String::New(env, + std::to_string(major) + "." + std::to_string(minor) + "." + + std::to_string(patch)); } static inline Napi::Object Capabilities(const Napi::Env& env) { diff --git a/src/observer.cc b/src/observer.cc index 01288dd1..f595ebc2 100644 --- a/src/observer.cc +++ b/src/observer.cc @@ -143,7 +143,7 @@ Observer::Observer(const Napi::CallbackInfo& info) /* Use `this` pointer as unique identifier for monitoring socket. */ auto address = std::string("inproc://zmq.monitor.") - + to_string(reinterpret_cast(this)); + + std::to_string(reinterpret_cast(this)); if (zmq_socket_monitor(target->socket, address.c_str(), ZMQ_EVENT_ALL) < 0) { ErrnoException(Env(), zmq_errno()).ThrowAsJavaScriptException(); diff --git a/src/proxy.cc b/src/proxy.cc index cf43fe05..520f2519 100644 --- a/src/proxy.cc +++ b/src/proxy.cc @@ -96,7 +96,7 @@ Napi::Value Proxy::Run(const Napi::CallbackInfo& info) { /* Use `this` pointer as unique identifier for control socket. */ auto address = std::string("inproc://zmq.proxycontrol.") - + to_string(reinterpret_cast(this)); + + std::to_string(reinterpret_cast(this)); /* Connect publisher so we can start queueing control messages. */ if (zmq_connect(control_pub, address.c_str()) < 0) { diff --git a/src/util/arguments.h b/src/util/arguments.h index 3d46fc31..e34359f7 100644 --- a/src/util/arguments.h +++ b/src/util/arguments.h @@ -4,8 +4,6 @@ #include -#include "to_string.h" - namespace zmq::Arg { using ValueMethod = bool (Napi::Value::*)() const; @@ -89,7 +87,8 @@ class Validator { [[nodiscard]] std::optional eval(const Napi::CallbackInfo& info) const { if constexpr (I == N) { if (info.Length() > N) { - auto msg = "Expected " + to_string(N) + " argument" + (N != 1 ? "s" : ""); + auto msg = + "Expected " + std::to_string(N) + " argument" + (N != 1 ? "s" : ""); return Napi::TypeError::New(info.Env(), msg); } diff --git a/src/util/to_string.h b/src/util/to_string.h deleted file mode 100644 index d75ef1f8..00000000 --- a/src/util/to_string.h +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once - -#include - -namespace zmq { -/* Provide an alternative, simplified std::to_string implementation for - integers to work around https://bugs.alpinelinux.org/issues/8626. */ -static inline std::string to_string(int64_t val) { - if (val == 0) { - return "0"; - } - std::string str; - - while (val > 0) { - str.insert(0, 1, val % 10 + 48); - val /= 10; - } - - return str; -} -} // namespace zmq