buffer: use constexpr where possible

PR-URL: https://github.com/nodejs/node/pull/58141
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
This commit is contained in:
Yagiz Nizipli
2025-05-06 12:53:37 -04:00
committed by GitHub
parent e272637d5e
commit 2c36ffec46

View File

@@ -1452,9 +1452,9 @@ uint32_t WriteOneByteString(const char* src,
return 0;
}
if (encoding == UTF8) {
if constexpr (encoding == UTF8) {
return simdutf::convert_latin1_to_utf8_safe(src, src_len, dst, dst_len);
} else if (encoding == LATIN1 || encoding == ASCII) {
} else if constexpr (encoding == LATIN1 || encoding == ASCII) {
const auto size = std::min(src_len, dst_len);
memcpy(dst, src, size);
return size;