Skip to content

Commit a711080

Browse files
tniessenjuanarbol
authored andcommitted
src: make Endianness an enum class
PR-URL: #44411 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Darshan Sen <[email protected]>
1 parent aa80826 commit a711080

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

‎src/util.h‎

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -748,26 +748,23 @@ inline v8::MaybeLocal<v8::Value> ToV8Value(v8::Local<v8::Context> context,
748748
.Check(); \
749749
} while (0)
750750

751-
enum Endianness{
752-
kLittleEndian, // _Not_ LITTLE_ENDIAN, clashes with endian.h.
753-
kBigEndian
754-
};
751+
enumclassEndianness{LITTLE, BIG };
755752

756-
inlineenumEndianness GetEndianness(){
753+
inline Endianness GetEndianness(){
757754
// Constant-folded by the compiler.
758755
constunion{
759756
uint8_tu8[2];
760757
uint16_tu16;
761758
} u ={{1, 0}};
762-
return u.u16 == 1 ? kLittleEndian : kBigEndian;
759+
return u.u16 == 1 ? Endianness::LITTLE : Endianness::BIG;
763760
}
764761

765762
inlineboolIsLittleEndian(){
766-
returnGetEndianness() == kLittleEndian;
763+
returnGetEndianness() == Endianness::LITTLE;
767764
}
768765

769766
inlineboolIsBigEndian(){
770-
returnGetEndianness() == kBigEndian;
767+
returnGetEndianness() == Endianness::BIG;
771768
}
772769

773770
// Round up a to the next highest multiple of b.

0 commit comments

Comments
(0)