Skip to content

Commit fd7c2be

Browse files
addaleaxBridgeAR
authored andcommitted
src: turn GET_OFFSET() into an inline function
There’s no need for this to be a macro. PR-URL: #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>
1 parent 00ed7d1 commit fd7c2be

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/node_file.cc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,10 @@ constexpr char kPathSeparator = '/';
8888
const char* const kPathSeparator = "\\/";
8989
#endif
9090

91-
#define GET_OFFSET(a) ((a)->IsNumber() ? (a).As<Integer>()->Value() : -1)
91+
inline int64_t GetOffset(Local<Value> value) {
92+
return value->IsNumber() ? value.As<Integer>()->Value() : -1;
93+
}
94+
9295
#define TRACE_NAME(name) "fs.sync." #name
9396
#define GET_TRACE_ENABLED \
9497
(*TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED \
@@ -1679,7 +1682,7 @@ static void WriteBuffer(const FunctionCallbackInfo<Value>& args) {
16791682
CHECK_LE(len, buffer_length);
16801683
CHECK_GE(off + len, off);
16811684

1682-
const int64_t pos = GET_OFFSET(args[4]);
1685+
const int64_t pos = GetOffset(args[4]);
16831686

16841687
char* buf = buffer_data + off;
16851688
uv_buf_t uvbuf = uv_buf_init(buf, len);
@@ -1719,7 +1722,7 @@ static void WriteBuffers(const FunctionCallbackInfo<Value>& args) {
17191722
CHECK(args[1]->IsArray());
17201723
Local<Array> chunks = args[1].As<Array>();
17211724

1722-
int64_t pos = GET_OFFSET(args[2]);
1725+
int64_t pos = GetOffset(args[2]);
17231726

17241727
MaybeStackBuffer<uv_buf_t> iovs(chunks->Length());
17251728

@@ -1763,7 +1766,7 @@ static void WriteString(const FunctionCallbackInfo<Value>& args) {
17631766
CHECK(args[0]->IsInt32());
17641767
const int fd = args[0].As<Int32>()->Value();
17651768

1766-
const int64_t pos = GET_OFFSET(args[2]);
1769+
const int64_t pos = GetOffset(args[2]);
17671770

17681771
const auto enc = ParseEncoding(isolate, args[3], UTF8);
17691772

0 commit comments

Comments
 (0)