Skip to content

Commit ddd71f4

Browse files
bnoordhuisrvagg
authored andcommitted
src: move function from header to source file
This particular Buffer::New() overload used to live in node_internals.h to work around a cyclic header dependency (IIRC) but that is no longer necessary. PR-URL: #26173 Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Minwoo Jung <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Yuta Hiroto <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
1 parent 5e44768 commit ddd71f4

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

src/node_buffer.cc

+14
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,20 @@ size_t Length(Local<Object> obj) {
234234
}
235235

236236

237+
inline MaybeLocal<Uint8Array> New(Environment* env,
238+
Local<ArrayBuffer> ab,
239+
size_t byte_offset,
240+
size_t length) {
241+
CHECK(!env->buffer_prototype_object().IsEmpty());
242+
Local<Uint8Array> ui = Uint8Array::New(ab, byte_offset, length);
243+
Maybe<bool> mb =
244+
ui->SetPrototype(env->context(), env->buffer_prototype_object());
245+
if (mb.IsNothing())
246+
return MaybeLocal<Uint8Array>();
247+
return ui;
248+
}
249+
250+
237251
MaybeLocal<Object> New(Isolate* isolate,
238252
Local<String> string,
239253
enum encoding enc) {

src/node_internals.h

-14
Original file line numberDiff line numberDiff line change
@@ -128,20 +128,6 @@ v8::MaybeLocal<v8::Object> New(Environment* env,
128128
// Mixing operator new and free() is undefined behavior so don't do that.
129129
v8::MaybeLocal<v8::Object> New(Environment* env, char* data, size_t length);
130130

131-
inline
132-
v8::MaybeLocal<v8::Uint8Array> New(Environment* env,
133-
v8::Local<v8::ArrayBuffer> ab,
134-
size_t byte_offset,
135-
size_t length) {
136-
v8::Local<v8::Uint8Array> ui = v8::Uint8Array::New(ab, byte_offset, length);
137-
CHECK(!env->buffer_prototype_object().IsEmpty());
138-
v8::Maybe<bool> mb =
139-
ui->SetPrototype(env->context(), env->buffer_prototype_object());
140-
if (mb.IsNothing())
141-
return v8::MaybeLocal<v8::Uint8Array>();
142-
return ui;
143-
}
144-
145131
// Construct a Buffer from a MaybeStackBuffer (and also its subclasses like
146132
// Utf8Value and TwoByteValue).
147133
// If |buf| is invalidated, an empty MaybeLocal is returned, and nothing is

0 commit comments

Comments
 (0)