[llvm] [Support] Modernize Uint24 in DataExtractor.h (NFC) (PR #165118)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sat Oct 25 13:26:18 PDT 2025
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/165118
We can use brace initializer lists to simplify constructors.
>From dcd96e1c8d2718430dd12e75bfddcadd46729fd9 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sun, 12 Oct 2025 15:51:44 -0700
Subject: [PATCH] [Support] Modernize Uint24 in DataExtractor.h (NFC)
We can use brace initializer lists to simplify constructors.
---
llvm/include/llvm/Support/DataExtractor.h | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
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