| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,3 @@ | |||
| 1 | + { | ||
| 2 | + ".": "0.1.3" | ||
| 3 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,8 @@ | |||
| 1 | + # Changelog | ||
| 2 | + | ||
| 3 | + ## [0.1.3](https://github.com/nodejs/nbytes/compare/v0.1.2...v0.1.3) (2026-02-18) | ||
| 4 | + | ||
| 5 | + | ||
| 6 | + ### Bug Fixes | ||
| 7 | + | ||
| 8 | + * use arithmetic HexEncode instead of lookups ([#12](https://github.com/nodejs/nbytes/issues/12)) ([8011baf](https://github.com/nodejs/nbytes/commit/8011baff1dfecf48b5feca21cb29b72e3562c919)) | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,5 @@ | |||
| 1 | 1 | cmake_minimum_required(VERSION 3.28) | |
| 2 | - project(nbytes) | ||
| 2 | + project(nbytes VERSION 0.1.3) # x-release-please-version | ||
| 3 | 3 | ||
| 4 | 4 | set(CMAKE_CXX_STANDARD 20) | |
| 5 | 5 | set(CMAKE_CXX_STANDARD_REQUIRED True) | |
@@ -40,3 +40,16 @@ install( | |||
| 40 | 40 | ARCHIVE COMPONENT nbytes_development | |
| 41 | 41 | INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" | |
| 42 | 42 | ) | |
| 43 | + | ||
| 44 | + # Configure and install pkg-config file | ||
| 45 | + configure_file( | ||
| 46 | + "${PROJECT_SOURCE_DIR}/nbytes.pc.in" | ||
| 47 | + "${PROJECT_BINARY_DIR}/nbytes.pc" | ||
| 48 | + @ONLY | ||
| 49 | + ) | ||
| 50 | + | ||
| 51 | + install( | ||
| 52 | + FILES "${PROJECT_BINARY_DIR}/nbytes.pc" | ||
| 53 | + DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig" | ||
| 54 | + COMPONENT nbytes_development | ||
| 55 | + ) | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -836,12 +836,12 @@ size_t SearchString(const char *haystack, size_t haystack_length, | |||
| 836 | 836 | ||
| 837 | 837 | // ============================================================================ | |
| 838 | 838 | // Version metadata | |
| 839 | - #define NBYTES_VERSION "0.1.1" | ||
| 839 | + #define NBYTES_VERSION "0.1.3" // x-release-please-version | ||
| 840 | 840 | ||
| 841 | 841 | enum { | |
| 842 | - NBYTES_VERSION_MAJOR = 0, | ||
| 843 | - NBYTES_VERSION_MINOR = 1, | ||
| 844 | - NBYTES_VERSION_REVISION = 1, | ||
| 842 | + NBYTES_VERSION_MAJOR = 0, // x-release-please-major | ||
| 843 | + NBYTES_VERSION_MINOR = 1, // x-release-please-minor | ||
| 844 | + NBYTES_VERSION_REVISION = 3, // x-release-please-patch | ||
| 845 | 845 | }; | |
| 846 | 846 | ||
| 847 | 847 | } // namespace nbytes | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,10 @@ | |||
| 1 | + prefix=@CMAKE_INSTALL_PREFIX@ | ||
| 2 | + exec_prefix=${prefix} | ||
| 3 | + libdir=@CMAKE_INSTALL_FULL_LIBDIR@ | ||
| 4 | + includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ | ||
| 5 | + | ||
| 6 | + Name: nbytes | ||
| 7 | + Description: Library of byte handling functions extracted from Node.js core | ||
| 8 | + Version: @PROJECT_VERSION@ | ||
| 9 | + Libs: -L${libdir} -lnbytes | ||
| 10 | + Cflags: -I${includedir} | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,11 @@ | |||
| 1 | + { | ||
| 2 | + "packages": { | ||
| 3 | + ".": { | ||
| 4 | + "release-type": "simple", | ||
| 5 | + "extra-files": [ | ||
| 6 | + "CMakeLists.txt", | ||
| 7 | + "include/nbytes.h" | ||
| 8 | + ] | ||
| 9 | + } | ||
| 10 | + } | ||
| 11 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -157,17 +157,21 @@ const int8_t unhex_table[256] = { | |||
| 157 | 157 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, | |
| 158 | 158 | -1, -1, -1, -1, -1, -1, -1, -1, -1}; | |
| 159 | 159 | ||
| 160 | + inline constexpr char nibble(uint8_t x) { | ||
| 161 | + uint8_t add = (x >= 10) ? ('a' - 10) : '0'; | ||
| 162 | + return x + add; | ||
| 163 | + } | ||
| 164 | + | ||
| 160 | 165 | size_t HexEncode(const char *src, size_t slen, char *dst, size_t dlen) { | |
| 161 | 166 | // We know how much we'll write, just make sure that there's space. | |
| 162 | 167 | NBYTES_ASSERT_TRUE(dlen >= MultiplyWithOverflowCheck<size_t>(slen, 2u) && | |
| 163 | 168 | "not enough space provided for hex encode"); | |
| 164 | 169 | ||
| 165 | 170 | dlen = slen * 2; | |
| 166 | 171 | for (size_t i = 0, k = 0; k < dlen; i += 1, k += 2) { | |
| 167 | - static const char hex[] = "0123456789abcdef"; | ||
| 168 | 172 | uint8_t val = static_cast<uint8_t>(src[i]); | |
| 169 | - dst[k + 0] = hex[val >> 4]; | ||
| 170 | - dst[k + 1] = hex[val & 15]; | ||
| 173 | + dst[k + 0] = nibble(val >> 4); | ||
| 174 | + dst[k + 1] = nibble(val & 15); | ||
| 171 | 175 | } | |
| 172 | 176 | ||
| 173 | 177 | return dlen; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments