Skip to content

Commit 00ed7d1

Browse files
addaleaxBridgeAR
authored andcommitted
src: inline SLICE_START_END() in node_buffer.cc
This macro is only used once, so it doesn’t need 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 1dc5ded commit 00ed7d1

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

src/node_buffer.cc

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,6 @@
4444
return node::THROW_ERR_OUT_OF_RANGE(env, "Index out of range"); \
4545
} while (0) \
4646

47-
#define SLICE_START_END(env, start_arg, end_arg, end_max) \
48-
size_t start = 0; \
49-
size_t end = 0; \
50-
THROW_AND_RETURN_IF_OOB(ParseArrayIndex(env, start_arg, 0, &start)); \
51-
THROW_AND_RETURN_IF_OOB(ParseArrayIndex(env, end_arg, end_max, &end)); \
52-
if (end < start) end = start; \
53-
THROW_AND_RETURN_IF_OOB(Just(end <= end_max)); \
54-
size_t length = end - start;
55-
5647
namespace node {
5748
namespace Buffer {
5849

@@ -467,7 +458,13 @@ void StringSlice(const FunctionCallbackInfo<Value>& args) {
467458
if (buffer.length() == 0)
468459
return args.GetReturnValue().SetEmptyString();
469460

470-
SLICE_START_END(env, args[0], args[1], buffer.length())
461+
size_t start = 0;
462+
size_t end = 0;
463+
THROW_AND_RETURN_IF_OOB(ParseArrayIndex(env, args[0], 0, &start));
464+
THROW_AND_RETURN_IF_OOB(ParseArrayIndex(env, args[1], buffer.length(), &end));
465+
if (end < start) end = start;
466+
THROW_AND_RETURN_IF_OOB(Just(end <= buffer.length()));
467+
size_t length = end - start;
471468

472469
Local<Value> error;
473470
MaybeLocal<Value> ret =

0 commit comments

Comments
 (0)