Skip to content

Commit 63fc6a6

Browse files
committed
string_bytes: export GetExternalParts
The method is useful elsewhere when needing to check if external and grab data.
1 parent 3ff2cbc commit 63fc6a6

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

src/string_bytes.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,12 +230,13 @@ size_t hex_decode(char* buf,
230230
}
231231

232232

233-
bool GetExternalParts(Handle<Value> val, const char** data, size_t* len) {
233+
bool StringBytes::GetExternalParts(Handle<Value> val,
234+
const char** data,
235+
size_t* len) {
234236
if (Buffer::HasInstance(val)) {
235237
*data = Buffer::Data(val);
236238
*len = Buffer::Length(val);
237239
return true;
238-
239240
}
240241

241242
assert(val->IsString());

src/string_bytes.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ class StringBytes {
4444
// very much slower for UTF-8
4545
static size_t Size(v8::Handle<v8::Value> val, enum encoding enc);
4646

47+
// If the string is external then assign external properties to data and len,
48+
// then return true. If not return false.
49+
static bool GetExternalParts(v8::Handle<v8::Value> val,
50+
const char** data,
51+
size_t* len);
52+
4753
// Write the bytes from the string or buffer into the char*
4854
// returns the number of bytes written, which will always be
4955
// <= buflen. Use StorageSize/Size first to know how much

0 commit comments

Comments
 (0)