summaryrefslogtreecommitdiff
path: root/src/node_file.cc
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2019-08-28 14:37:18 +0200
committerDaniel Bevenius <daniel.bevenius@gmail.com>2019-09-02 07:57:06 +0200
commit0f3aa81eab383ab85b5b84d6fe4570115d824a64 (patch)
treece7fef83cb0df157314d3499d5a6d2c212939740 /src/node_file.cc
parent5a52bdad9ba95ef20a8af1a1f2bd72c008cbf2f1 (diff)
downloadandroid-node-v8-0f3aa81eab383ab85b5b84d6fe4570115d824a64.tar.gz
android-node-v8-0f3aa81eab383ab85b5b84d6fe4570115d824a64.tar.bz2
android-node-v8-0f3aa81eab383ab85b5b84d6fe4570115d824a64.zip
src: turn `GET_OFFSET()` into an inline function
There’s no need for this to be a macro. PR-URL: https://github.com/nodejs/node/pull/29357 Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Masashi Hirano <shisama07@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Diffstat (limited to 'src/node_file.cc')
-rw-r--r--src/node_file.cc11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/node_file.cc b/src/node_file.cc
index c4e3b83392..ae2aa0677f 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) (IsSafeJsInt(a) ? (a).As<Integer>()->Value() : -1)
+inline int64_t GetOffset(Local<Value> value) {
+ return IsSafeJsInt(value) ? value.As<Integer>()->Value() : -1;
+}
+
#define TRACE_NAME(name) "fs.sync." #name
#define GET_TRACE_ENABLED \
(*TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED \
@@ -1681,7 +1684,7 @@ static void WriteBuffer(const FunctionCallbackInfo<Value>& 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);
@@ -1721,7 +1724,7 @@ static void WriteBuffers(const FunctionCallbackInfo<Value>& args) {
CHECK(args[1]->IsArray());
Local<Array> chunks = args[1].As<Array>();
- int64_t pos = GET_OFFSET(args[2]);
+ int64_t pos = GetOffset(args[2]);
MaybeStackBuffer<uv_buf_t> iovs(chunks->Length());
@@ -1765,7 +1768,7 @@ static void WriteString(const FunctionCallbackInfo<Value>& args) {
CHECK(args[0]->IsInt32());
const int fd = args[0].As<Int32>()->Value();
- const int64_t pos = GET_OFFSET(args[2]);
+ const int64_t pos = GetOffset(args[2]);
const auto enc = ParseEncoding(isolate, args[3], UTF8);