mirror of
https://github.com/nodejs/node.git
synced 2026-10-14 10:26:26 -04:00
src: make FIXED_ONE_BYTE_STRING an inline fn
This prevents accidental usage on non-fixed strings. PR-URL: https://github.com/nodejs/node/pull/22725 Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Minwoo Jung <minwoo@nodesource.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
1 parent
33eb509df6
commit
932a74ae74
2 files changed
+11
-5
No files matched your search
+2
-2
@@ -2173,11 +2173,11 @@ static napi_status set_error_code(napi_env env,
|
||||
}
|
||||
}
|
||||
name_string = v8::String::Concat(
|
||||
isolate, name_string, FIXED_ONE_BYTE_STRING(isolate, " ["));
|
||||
isolate, name_string, node::FIXED_ONE_BYTE_STRING(isolate, " ["));
|
||||
name_string =
|
||||
v8::String::Concat(isolate, name_string, code_value.As<v8::String>());
|
||||
name_string = v8::String::Concat(
|
||||
isolate, name_string, FIXED_ONE_BYTE_STRING(isolate, "]"));
|
||||
isolate, name_string, node::FIXED_ONE_BYTE_STRING(isolate, "]"));
|
||||
|
||||
set_maybe = err_object->Set(context, name_key, name_string);
|
||||
RETURN_STATUS_IF_FALSE(env,
|
||||
|
||||
+9
-3
@@ -89,9 +89,6 @@ NO_RETURN void Abort();
|
||||
NO_RETURN void Assert(const char* const (*args)[4]);
|
||||
void DumpBacktrace(FILE* fp);
|
||||
|
||||
#define FIXED_ONE_BYTE_STRING(isolate, string) \
|
||||
(node::OneByteString((isolate), (string), sizeof(string) - 1))
|
||||
|
||||
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
|
||||
void operator=(const TypeName&) = delete; \
|
||||
void operator=(TypeName&&) = delete; \
|
||||
@@ -248,6 +245,15 @@ inline v8::Local<v8::String> OneByteString(v8::Isolate* isolate,
|
||||
const unsigned char* data,
|
||||
int length = -1);
|
||||
|
||||
// Used to be a macro, hence the uppercase name.
|
||||
template <int N>
|
||||
inline v8::Local<v8::String> FIXED_ONE_BYTE_STRING(
|
||||
v8::Isolate* isolate,
|
||||
const char(&data)[N]) {
|
||||
return OneByteString(isolate, data, N - 1);
|
||||
}
|
||||
|
||||
|
||||
// Swaps bytes in place. nbytes is the number of bytes to swap and must be a
|
||||
// multiple of the word size (checked by function).
|
||||
inline void SwapBytes16(char* data, size_t nbytes);
|
||||
|
||||
Reference in new issue
Block a user