Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions deps/nbytes/.release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
".": "0.1.3"
}
8 changes: 8 additions & 0 deletions deps/nbytes/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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))
15 changes: 14 additions & 1 deletion deps/nbytes/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.28)
project(nbytes)
project(nbytes VERSION 0.1.3) # x-release-please-version

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED True)
Expand Down Expand Up @@ -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
)
8 changes: 4 additions & 4 deletions deps/nbytes/include/nbytes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.3" // 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 = 3, // x-release-please-patch
};

} // namespace nbytes
Expand Down
10 changes: 10 additions & 0 deletions deps/nbytes/nbytes.pc.in
Original file line number Diff line number Diff line change
@@ -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}
11 changes: 11 additions & 0 deletions deps/nbytes/release-please-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"packages": {
".": {
"release-type": "simple",
"extra-files": [
"CMakeLists.txt",
"include/nbytes.h"
]
}
}
}
10 changes: 7 additions & 3 deletions deps/nbytes/src/nbytes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,17 +157,21 @@ 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<size_t>(slen, 2u) &&
"not enough space provided for hex encode");

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<uint8_t>(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;
Expand Down
Loading