From 00f48a0620cef800054d4aab061f09d89990a1b9 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Mon, 5 Jan 2026 22:09:22 +0100 Subject: [PATCH 1/4] chore: add pkgconfig support (#10) --- CMakeLists.txt | 15 ++++++++++++++- nbytes.pc.in | 10 ++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 nbytes.pc.in diff --git a/CMakeLists.txt b/CMakeLists.txt index f2efa3c..2dade34 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.28) -project(nbytes) +project(nbytes VERSION 0.1.2) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED True) @@ -40,3 +40,16 @@ install( ARCHIVE COMPONENT nbytes_development INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" ) + +# Configure and install pkg-config file +configure_file( + "${PROJECT_SOURCE_DIR}/nbytes.pc.in" + "${PROJECT_BINARY_DIR}/nbytes.pc" + @ONLY +) + +install( + FILES "${PROJECT_BINARY_DIR}/nbytes.pc" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig" + COMPONENT nbytes_development +) diff --git a/nbytes.pc.in b/nbytes.pc.in new file mode 100644 index 0000000..24119b1 --- /dev/null +++ b/nbytes.pc.in @@ -0,0 +1,10 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=${prefix} +libdir=@CMAKE_INSTALL_FULL_LIBDIR@ +includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ + +Name: nbytes +Description: Library of byte handling functions extracted from Node.js core +Version: @PROJECT_VERSION@ +Libs: -L${libdir} -lnbytes +Cflags: -I${includedir} From 512d762ec82c1a5d83c34fa3fbf95e6227764b5f Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Mon, 2 Feb 2026 18:02:14 +0100 Subject: [PATCH 2/4] chore: add Release Please GHA workflow (#11) --- .github/workflows/release-please.yml | 16 ++++++++++++++++ .release-please-manifest.json | 3 +++ CMakeLists.txt | 2 +- include/nbytes.h | 8 ++++---- release-please-config.json | 11 +++++++++++ 5 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/release-please.yml create mode 100644 .release-please-manifest.json create mode 100644 release-please-config.json diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml new file mode 100644 index 0000000..57f8a91 --- /dev/null +++ b/.github/workflows/release-please.yml @@ -0,0 +1,16 @@ +name: Release Please + +on: + push: + branches: + - main + +permissions: + contents: write + pull-requests: write + +jobs: + release-please: + runs-on: ubuntu-latest + steps: + - uses: googleapis/release-please-action@16a9c90856f42705d54a6fda1823352bdc62cf38 # v4.4.0 diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 0000000..001eb2c --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1,3 @@ +{ + ".": "0.1.2" +} diff --git a/CMakeLists.txt b/CMakeLists.txt index 2dade34..bf4b059 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.28) -project(nbytes VERSION 0.1.2) +project(nbytes VERSION 0.1.2) # x-release-please-version set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED True) diff --git a/include/nbytes.h b/include/nbytes.h index 525a917..7fa347b 100644 --- a/include/nbytes.h +++ b/include/nbytes.h @@ -836,12 +836,12 @@ size_t SearchString(const char *haystack, size_t haystack_length, // ============================================================================ // Version metadata -#define NBYTES_VERSION "0.1.1" +#define NBYTES_VERSION "0.1.2" // x-release-please-version enum { - NBYTES_VERSION_MAJOR = 0, - NBYTES_VERSION_MINOR = 1, - NBYTES_VERSION_REVISION = 1, + NBYTES_VERSION_MAJOR = 0, // x-release-please-major + NBYTES_VERSION_MINOR = 1, // x-release-please-minor + NBYTES_VERSION_REVISION = 2, // x-release-please-patch }; } // namespace nbytes diff --git a/release-please-config.json b/release-please-config.json new file mode 100644 index 0000000..0793045 --- /dev/null +++ b/release-please-config.json @@ -0,0 +1,11 @@ +{ + "packages": { + ".": { + "release-type": "simple", + "extra-files": [ + "CMakeLists.txt", + "include/nbytes.h" + ] + } + } +} From 8011baff1dfecf48b5feca21cb29b72e3562c919 Mon Sep 17 00:00:00 2001 From: Nikita Skovoroda Date: Wed, 11 Feb 2026 19:31:41 +0300 Subject: [PATCH 3/4] fix: use arithmetic HexEncode instead of lookups (#12) * src: use arithmetic HexEncode instead of lookups * fixup!: lint * fixup!: constexpr Co-authored-by: Yagiz Nizipli * fixup!: more clear code * fixup!: lint --------- Co-authored-by: Yagiz Nizipli --- src/nbytes.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/nbytes.cpp b/src/nbytes.cpp index a827809..09e2665 100644 --- a/src/nbytes.cpp +++ b/src/nbytes.cpp @@ -157,6 +157,11 @@ const int8_t unhex_table[256] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}; +inline constexpr char nibble(uint8_t x) { + uint8_t add = (x >= 10) ? ('a' - 10) : '0'; + return x + add; +} + size_t HexEncode(const char *src, size_t slen, char *dst, size_t dlen) { // We know how much we'll write, just make sure that there's space. NBYTES_ASSERT_TRUE(dlen >= MultiplyWithOverflowCheck(slen, 2u) && @@ -164,10 +169,9 @@ size_t HexEncode(const char *src, size_t slen, char *dst, size_t dlen) { dlen = slen * 2; for (size_t i = 0, k = 0; k < dlen; i += 1, k += 2) { - static const char hex[] = "0123456789abcdef"; uint8_t val = static_cast(src[i]); - dst[k + 0] = hex[val >> 4]; - dst[k + 1] = hex[val & 15]; + dst[k + 0] = nibble(val >> 4); + dst[k + 1] = nibble(val & 15); } return dlen; From 1a62f8e1eb3bd529ea7cdabb718f8ec06bba363f Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 18 Feb 2026 11:20:49 +0100 Subject: [PATCH 4/4] chore(main): release 0.1.3 (#13) --- .release-please-manifest.json | 2 +- CHANGELOG.md | 8 ++++++++ CMakeLists.txt | 2 +- include/nbytes.h | 4 ++-- 4 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 CHANGELOG.md diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 001eb2c..c05df9b 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.1.2" + ".": "0.1.3" } diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..067a946 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,8 @@ +# Changelog + +## [0.1.3](https://github.com/nodejs/nbytes/compare/v0.1.2...v0.1.3) (2026-02-18) + + +### Bug Fixes + +* use arithmetic HexEncode instead of lookups ([#12](https://github.com/nodejs/nbytes/issues/12)) ([8011baf](https://github.com/nodejs/nbytes/commit/8011baff1dfecf48b5feca21cb29b72e3562c919)) diff --git a/CMakeLists.txt b/CMakeLists.txt index bf4b059..5ac0e31 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.28) -project(nbytes VERSION 0.1.2) # x-release-please-version +project(nbytes VERSION 0.1.3) # x-release-please-version set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED True) diff --git a/include/nbytes.h b/include/nbytes.h index 7fa347b..3a2bcc6 100644 --- a/include/nbytes.h +++ b/include/nbytes.h @@ -836,12 +836,12 @@ size_t SearchString(const char *haystack, size_t haystack_length, // ============================================================================ // Version metadata -#define NBYTES_VERSION "0.1.2" // x-release-please-version +#define NBYTES_VERSION "0.1.3" // x-release-please-version enum { NBYTES_VERSION_MAJOR = 0, // x-release-please-major NBYTES_VERSION_MINOR = 1, // x-release-please-minor - NBYTES_VERSION_REVISION = 2, // x-release-please-patch + NBYTES_VERSION_REVISION = 3, // x-release-please-patch }; } // namespace nbytes