mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-11 13:30:47 -04:00
refactor: use static_cast instead of reinterpret_cast
This commit is contained in:
parent
5b8e7acbc9
commit
bdb5469b7b
@ -22,6 +22,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <concepts>
|
||||
#include <cstddef>
|
||||
#include <filesystem>
|
||||
#include <span>
|
||||
#include <string>
|
||||
@ -47,8 +48,9 @@ class mmif : public boost::noncopyable {
|
||||
|
||||
template <typename T, std::integral U>
|
||||
T const* as(U offset = 0) const {
|
||||
return reinterpret_cast<T const*>(
|
||||
reinterpret_cast<char const*>(this->addr()) + offset);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic)
|
||||
auto raw = static_cast<std::byte const*>(this->addr()) + offset;
|
||||
return static_cast<T const*>(static_cast<void const*>(raw));
|
||||
}
|
||||
|
||||
template <typename T = uint8_t, std::integral U>
|
||||
|
@ -37,8 +37,8 @@ namespace {
|
||||
struct lz4_compression_policy {
|
||||
static size_t compress(const void* src, void* dest, size_t size,
|
||||
size_t destsize, int /*level*/) {
|
||||
return to<size_t>(LZ4_compress_default(reinterpret_cast<const char*>(src),
|
||||
reinterpret_cast<char*>(dest),
|
||||
return to<size_t>(LZ4_compress_default(static_cast<const char*>(src),
|
||||
static_cast<char*>(dest),
|
||||
to<int>(size), to<int>(destsize)));
|
||||
}
|
||||
|
||||
@ -48,9 +48,9 @@ struct lz4_compression_policy {
|
||||
struct lz4hc_compression_policy {
|
||||
static size_t compress(const void* src, void* dest, size_t size,
|
||||
size_t destsize, int level) {
|
||||
return to<size_t>(LZ4_compress_HC(reinterpret_cast<const char*>(src),
|
||||
reinterpret_cast<char*>(dest),
|
||||
to<int>(size), to<int>(destsize), level));
|
||||
return to<size_t>(LZ4_compress_HC(static_cast<const char*>(src),
|
||||
static_cast<char*>(dest), to<int>(size),
|
||||
to<int>(destsize), level));
|
||||
}
|
||||
|
||||
static std::string describe(int level) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user