From b964bdd1629bbfee538b0c43065b7d9dd4be7b7d Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Wed, 28 Aug 2019 14:37:18 +0200 Subject: [PATCH] src: turn `GET_OFFSET()` into an inline function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There’s no need for this to be a macro. PR-URL: https://github.com/nodejs/node/pull/29357 Reviewed-By: Jiawen Geng Reviewed-By: Masashi Hirano Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca Reviewed-By: James M Snell Reviewed-By: Richard Lau Reviewed-By: Michael Dawson --- src/node_file.cc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/node_file.cc b/src/node_file.cc index 138848c49da45e..ad55d501b4e8df 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -88,7 +88,10 @@ constexpr char kPathSeparator = '/'; const char* const kPathSeparator = "\\/"; #endif -#define GET_OFFSET(a) ((a)->IsNumber() ? (a).As()->Value() : -1) +inline int64_t GetOffset(Local value) { + return value->IsNumber() ? value.As()->Value() : -1; +} + #define TRACE_NAME(name) "fs.sync." #name #define GET_TRACE_ENABLED \ (*TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED \ @@ -1679,7 +1682,7 @@ static void WriteBuffer(const FunctionCallbackInfo& args) { CHECK_LE(len, buffer_length); CHECK_GE(off + len, off); - const int64_t pos = GET_OFFSET(args[4]); + const int64_t pos = GetOffset(args[4]); char* buf = buffer_data + off; uv_buf_t uvbuf = uv_buf_init(buf, len); @@ -1719,7 +1722,7 @@ static void WriteBuffers(const FunctionCallbackInfo& args) { CHECK(args[1]->IsArray()); Local chunks = args[1].As(); - int64_t pos = GET_OFFSET(args[2]); + int64_t pos = GetOffset(args[2]); MaybeStackBuffer iovs(chunks->Length()); @@ -1763,7 +1766,7 @@ static void WriteString(const FunctionCallbackInfo& args) { CHECK(args[0]->IsInt32()); const int fd = args[0].As()->Value(); - const int64_t pos = GET_OFFSET(args[2]); + const int64_t pos = GetOffset(args[2]); const auto enc = ParseEncoding(isolate, args[3], UTF8);