summaryrefslogtreecommitdiff
path: root/src/string_bytes.cc
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2014-12-10 17:45:50 +0100
committerBen Noordhuis <info@bnoordhuis.nl>2014-12-14 16:01:47 +0100
commit52fc4063083f5dd0ee844b3abd7fdc3b56787db9 (patch)
tree2a2ff0e06c1f5538093a6d84b101fd1293be58a0 /src/string_bytes.cc
parent56fde66c46653e5c0fbc6e8960d8a013af35f42b (diff)
downloadandroid-node-v8-52fc4063083f5dd0ee844b3abd7fdc3b56787db9.tar.gz
android-node-v8-52fc4063083f5dd0ee844b3abd7fdc3b56787db9.tar.bz2
android-node-v8-52fc4063083f5dd0ee844b3abd7fdc3b56787db9.zip
src: move BE/LE buffer conversion to StringSlice()
Move the big endian to little endian conversion logic for UCS2 input from src/string_bytes.cc to src/node_buffer.cc; StringSlice() is the only function that actually needs it and with this commit, a second copy is avoided on big endian architectures.
Diffstat (limited to 'src/string_bytes.cc')
-rw-r--r--src/string_bytes.cc13
1 files changed, 0 insertions, 13 deletions
diff --git a/src/string_bytes.cc b/src/string_bytes.cc
index e646087b9d..f1ff697452 100644
--- a/src/string_bytes.cc
+++ b/src/string_bytes.cc
@@ -777,19 +777,6 @@ Local<Value> StringBytes::Encode(Isolate* isolate,
size_t buflen) {
const uint16_t* src = buf;
- // Node's "ucs2" encoding expects LE character data inside a
- // Buffer, so we need to reorder on BE platforms. See
- // http://nodejs.org/api/buffer.html regarding Node's "ucs2"
- // encoding specification.
- if (IsBigEndian()) {
- // Inefficient, see StringSlice<UCS2>() in src/node_buffer.cc;
- // this is potentially the second copy of the actual input.
- uint16_t* copy = new uint16_t[buflen];
- for (size_t i = 0; i < buflen; i += 1)
- copy[i] = buf[i] << 8 | buf[i] >> 8;
- src = copy;
- }
-
Local<String> val;
if (buflen < EXTERN_APEX) {
val = String::NewFromTwoByte(isolate,