Skip to content

Commit dc02563

Browse files
bnoordhuisMichael Scovetta
authored andcommitted
src: remove __builtin_bswap16 call
Not supported by apple-gcc and I'm not convinced it's worth adding more preprocessor hacks when it should be easy as pie for the compiler to to optimize the byteswap. If it doesn't, fix the compiler. Fixes: nodejs#4284 PR-URL: nodejs#4290 Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent 304932d commit dc02563

1 file changed

Lines changed: 1 addition & 8 deletions

File tree

src/util-inl.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -199,15 +199,8 @@ TypeName* Unwrap(v8::Local<v8::Object> object) {
199199
}
200200

201201
void SwapBytes(uint16_t* dst, const uint16_t* src, size_t buflen) {
202-
for (size_t i = 0; i < buflen; i++) {
203-
// __builtin_bswap16 generates more efficient code with
204-
// g++ 4.8 on PowerPC and other big-endian archs
205-
#ifdef __GNUC__
206-
dst[i] = __builtin_bswap16(src[i]);
207-
#else
202+
for (size_t i = 0; i < buflen; i += 1)
208203
dst[i] = (src[i] << 8) | (src[i] >> 8);
209-
#endif
210-
}
211204
}
212205

213206

0 commit comments

Comments
 (0)