Skip to content

Commit 0e269a7

Browse files
bnoordhuisMyles Borins
authored and
Myles Borins
committed
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: #4284 PR-URL: #4290 Reviewed-By: Colin Ihrig <[email protected]>
1 parent 7ab7402 commit 0e269a7

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

src/util-inl.h

+1-8
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)