[llvm] e219cf6 - [Support] Modernize Uint24 in DataExtractor.h (NFC) (#165118)

via llvm-commits llvm-commits at lists.llvm.org
Sat Oct 25 15:46:55 PDT 2025


Author: Kazu Hirata
Date: 2025-10-25T15:46:51-07:00
New Revision: e219cf60598c2c133a29170f7a9f9e793e429cc2

URL: https://github.com/llvm/llvm-project/commit/e219cf60598c2c133a29170f7a9f9e793e429cc2
DIFF: https://github.com/llvm/llvm-project/commit/e219cf60598c2c133a29170f7a9f9e793e429cc2.diff

LOG: [Support] Modernize Uint24 in DataExtractor.h (NFC) (#165118)

We can use brace initializer lists to simplify constructors.

Added: 
    

Modified: 
    llvm/include/llvm/Support/DataExtractor.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Support/DataExtractor.h b/llvm/include/llvm/Support/DataExtractor.h
index 3792f53407dd9..f1710b918ce78 100644
--- a/llvm/include/llvm/Support/DataExtractor.h
+++ b/llvm/include/llvm/Support/DataExtractor.h
@@ -19,12 +19,8 @@ namespace llvm {
 /// An auxiliary type to facilitate extraction of 3-byte entities.
 struct Uint24 {
   uint8_t Bytes[3];
-  Uint24(uint8_t U) {
-    Bytes[0] = Bytes[1] = Bytes[2] = U;
-  }
-  Uint24(uint8_t U0, uint8_t U1, uint8_t U2) {
-    Bytes[0] = U0; Bytes[1] = U1; Bytes[2] = U2;
-  }
+  Uint24(uint8_t U) : Bytes{U, U, U} {}
+  Uint24(uint8_t U0, uint8_t U1, uint8_t U2) : Bytes{U0, U1, U2} {}
   uint32_t getAsUint32(bool IsLittleEndian) const {
     int LoIx = IsLittleEndian ? 0 : 2;
     return Bytes[LoIx] + (Bytes[1] << 8) + (Bytes[2-LoIx] << 16);


        


More information about the llvm-commits mailing list