Skip to content

优化算法库的代码#91

Merged
owent merged 2 commits into
mainfrom
dev
May 14, 2026
Merged

优化算法库的代码#91
owent merged 2 commits into
mainfrom
dev

Conversation

@owent

@owent owent commented May 14, 2026

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI review requested due to automatic review settings May 14, 2026 10:06

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR modernizes the algorithm library: it replaces C-style headers with C++ counterparts, swaps C-style casts for static_cast, moves internal symbols from namespace detail into anonymous namespaces with ATFW_UTIL_SYMBOL_LOCAL, adds noexcept on move/swap, rewrites MurmurHash block-reading to handle unaligned input safely with may-alias struct wrappers, and cleans up a few incidental bugs.

Changes:

  • Refactor algorithm sources (sha, base64, crc, xxtea, murmur_hash, crypto_*, compression) for consistent style, modern casts, anonymous namespaces, and .data() accessors instead of &v[0].
  • Fix several latent bugs: SHA-512 free/init/start using the wrong sha384_context, missing case EN_CIMT_LIBSODIUM_XCHACHA20: in cipher encrypt/decrypt switches, MurmurHash unaligned-load safety on strict-alignment platforms.
  • Add MurmurHash known-answer reference vector tests and aligned-vs-unaligned input equivalence tests; relax clang-tidy with -misc-include-cleaner and -readability-use-concise-preprocessor-directives.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.

Show a summary per file
File Description
.clang-tidy Disable misc-include-cleaner and readability-use-concise-preprocessor-directives checks.
include/algorithm/sha.h Add noexcept to move ctor/assign and swap.
include/algorithm/compression.h Drop unused <string> include.
src/algorithm/base64.cpp Move helpers to anonymous namespace, modernize casts, add get_writable_string_data shim.
src/algorithm/compression.cpp Wrap output.resize in exception-safe helper, reserve algorithm vector with try/catch.
src/algorithm/crc.cpp Move tables to anonymous namespace, modern casts, drop legacy C headers.
src/algorithm/crypto_cipher.cpp Convert enums to scoped, replace static counter with Meyers singleton, use .data(), fix missing XCHACHA20 case label.
src/algorithm/crypto_dh.cpp Add tls_curve_info ctor for anonymous-namespace constexpr table, use .data(), modernize casts, std::move shared context.
src/algorithm/crypto_hmac.cpp Anonymous namespace + ATFW_UTIL_SYMBOL_LOCAL, get_writable_string_data shim, return {} instead of explicit empty vectors.
src/algorithm/murmur_hash.cpp Replace MSVC/non-MSVC fork with portable rotl + may-alias unaligned reads, restructure block iteration loops.
src/algorithm/sha.cpp Rename inner→internal, anonymous namespace, fix SHA-512 context misuses, add noexcept to move/swap.
src/algorithm/xxtea.cpp Anonymous namespace + symbol-local on helper templates, modern casts, std::abort.
test/case/murmur_hash_test.cpp Add reference-vector and unaligned-input parity tests.

@owent owent merged commit 80e2b38 into main May 14, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants