Skip to content

Commit

Permalink
chore: just export whats needed in xxh3
Browse files Browse the repository at this point in the history
  • Loading branch information
zaucy committed Nov 27, 2024
1 parent 00724d3 commit d121074
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
6 changes: 1 addition & 5 deletions src/main.cpp2
Original file line number Diff line number Diff line change
Expand Up @@ -767,10 +767,7 @@ hash_file: (p: fs::path) -> u64 = {
buffer.resize(size);
f.read(buffer.data(), size);
if f.fail() { return 0; }
return constexpr_xxh3::XXH3_64bits(buffer.data(), buffer.size());
}

cpp2b_data_file: type = {
return XXH3_64bits(buffer.data(), buffer.size());
}

do_build: (targets: std::vector<std::string>) -> (stuff: full_build_info, exit_code: int) = {
Expand Down Expand Up @@ -833,7 +830,6 @@ do_build: (targets: std::vector<std::string>) -> (stuff: full_build_info, exit_c
transpile_futures: std::vector<std::future<transpile_cpp2_result>> = ();
cpp2b_parse_futures: std::vector<std::future<cpp2b_source_info>> = ();
file_hash_futures: std::unordered_map<fs::path, std::future<u64>> = ();
file_hash_futures: std::unordered_map<fs::path, std::future<u64>> = ();

transpile_futures.reserve(cpp2_source_files.size());
cpp2b_parse_futures.reserve(cpp2_source_files.size());
Expand Down
17 changes: 6 additions & 11 deletions src/xxh3.cppm
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ module;

export module xxh3;

export namespace constexpr_xxh3 {

template <typename T>
concept ByteType = (std::is_integral_v<T> && sizeof(T) == 1)
#if defined __cpp_lib_byte && __cpp_lib_byte >= 201603
Expand Down Expand Up @@ -300,7 +298,7 @@ constexpr size_t bytes_size(T (&)[N]) noexcept {

/// Basic interfaces

template <ByteType T>
export template <ByteType T>
constexpr uint64_t XXH3_64bits(const T* input, size_t len) noexcept {
return XXH3_64bits_internal(
input, len, 0, kSecret, sizeof(kSecret),
Expand All @@ -310,7 +308,7 @@ constexpr uint64_t XXH3_64bits(const T* input, size_t len) noexcept {
});
}

template <ByteType T, ByteType S>
export template <ByteType T, ByteType S>
constexpr uint64_t XXH3_64bits_withSecret(const T* input, size_t len,
const S* secret,
size_t secretSize) noexcept {
Expand All @@ -322,7 +320,7 @@ constexpr uint64_t XXH3_64bits_withSecret(const T* input, size_t len,
});
}

template <ByteType T>
export template <ByteType T>
constexpr uint64_t XXH3_64bits_withSeed(const T* input, size_t len,
uint64_t seed) noexcept {
if (seed == 0) return XXH3_64bits(input, len);
Expand All @@ -341,24 +339,21 @@ constexpr uint64_t XXH3_64bits_withSeed(const T* input, size_t len,

/// Convenient interfaces

template <BytesType Bytes>
export template <BytesType Bytes>
constexpr uint64_t XXH3_64bits(const Bytes& input) noexcept {
return XXH3_64bits(std::data(input), bytes_size(input));
}

template <BytesType Bytes, BytesType Secret>
export template <BytesType Bytes, BytesType Secret>
constexpr uint64_t XXH3_64bits_withSecret(const Bytes& input,
const Secret& secret) noexcept {
return XXH3_64bits_withSecret(std::data(input), bytes_size(input),
std::data(secret), bytes_size(secret));
}

template <BytesType Bytes>
export template <BytesType Bytes>
constexpr uint64_t XXH3_64bits_withSeed(const Bytes& input,
uint64_t seed) noexcept {
return XXH3_64bits_withSeed(std::data(input), bytes_size(input), seed);
}

} // namespace constexpr_xxh3


0 comments on commit d121074

Please sign in to comment.