Skip to content

Commit 0f3aa81

Browse files
addaleaxdanbev
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 <[email protected]> Reviewed-By: Masashi Hirano <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
1 parent 5a52bda commit 0f3aa81

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) (IsSafeJsInt(a) ? (a).As<Integer>()->Value() : -1)
91+
inline int64_t GetOffset(Local<Value> value) {
92+
return IsSafeJsInt(value) ? 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 \
@@ -1681,7 +1684,7 @@ static void WriteBuffer(const FunctionCallbackInfo<Value>& args) {
16811684
CHECK_LE(len, buffer_length);
16821685
CHECK_GE(off + len, off);
16831686

1684-
const int64_t pos = GET_OFFSET(args[4]);
1687+
const int64_t pos = GetOffset(args[4]);
16851688

16861689
char* buf = buffer_data + off;
16871690
uv_buf_t uvbuf = uv_buf_init(buf, len);
@@ -1721,7 +1724,7 @@ static void WriteBuffers(const FunctionCallbackInfo<Value>& args) {
17211724
CHECK(args[1]->IsArray());
17221725
Local<Array> chunks = args[1].As<Array>();
17231726

1724-
int64_t pos = GET_OFFSET(args[2]);
1727+
int64_t pos = GetOffset(args[2]);
17251728

17261729
MaybeStackBuffer<uv_buf_t> iovs(chunks->Length());
17271730

@@ -1765,7 +1768,7 @@ static void WriteString(const FunctionCallbackInfo<Value>& args) {
17651768
CHECK(args[0]->IsInt32());
17661769
const int fd = args[0].As<Int32>()->Value();
17671770

1768-
const int64_t pos = GET_OFFSET(args[2]);
1771+
const int64_t pos = GetOffset(args[2]);
17691772

17701773
const auto enc = ParseEncoding(isolate, args[3], UTF8);
17711774

0 commit comments

Comments
 (0)