Skip to content

Commit 9f7906a

Browse files
[Support] Remove redundant forwarding functions read/write (NFC) (#66051)
We don't need these forwarding functions if we add a default template parameter to their callees.
1 parent da35b2e commit 9f7906a

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

llvm/include/llvm/Support/Endian.h

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ inline value_type byte_swap(value_type value) {
5959
}
6060

6161
/// Read a value of a particular endianness from memory.
62-
template <typename value_type, std::size_t alignment>
62+
template <typename value_type, std::size_t alignment = unaligned>
6363
inline value_type read(const void *memory, endianness endian) {
6464
value_type ret;
6565

@@ -93,7 +93,7 @@ inline value_type readNext(const CharT *&memory) {
9393
}
9494

9595
/// Write a value to memory with a particular endianness.
96-
template <typename value_type, std::size_t alignment>
96+
template <typename value_type, std::size_t alignment = unaligned>
9797
inline void write(void *memory, value_type value, endianness endian) {
9898
value = byte_swap<value_type>(value, endian);
9999
memcpy(LLVM_ASSUME_ALIGNED(
@@ -349,10 +349,6 @@ using aligned_big_t = detail::packed_endian_specific_integral<T, big, aligned>;
349349

350350
namespace endian {
351351

352-
template <typename T> inline T read(const void *P, endianness E) {
353-
return read<T, unaligned>(P, E);
354-
}
355-
356352
template <typename T, endianness E> inline T read(const void *P) {
357353
return *(const detail::packed_endian_specific_integral<T, E, unaligned> *)P;
358354
}
@@ -384,10 +380,6 @@ inline uint16_t read16be(const void *P) { return read16<big>(P); }
384380
inline uint32_t read32be(const void *P) { return read32<big>(P); }
385381
inline uint64_t read64be(const void *P) { return read64<big>(P); }
386382

387-
template <typename T> inline void write(void *P, T V, endianness E) {
388-
write<T, unaligned>(P, V, E);
389-
}
390-
391383
template <typename T, endianness E> inline void write(void *P, T V) {
392384
*(detail::packed_endian_specific_integral<T, E, unaligned> *)P = V;
393385
}

0 commit comments

Comments
 (0)