From bb39fbbb44bf2131c99dacd2326c8e346a20f0fa Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Thu, 13 Mar 2025 09:37:46 -0400 Subject: [PATCH] removing dead code --- include/simdjson/arm64/stringparsing_defs.h | 36 ------------------ .../simdjson/fallback/stringparsing_defs.h | 14 ------- include/simdjson/haswell/stringparsing_defs.h | 36 ------------------ include/simdjson/icelake/stringparsing_defs.h | 37 ------------------- include/simdjson/lasx/stringparsing_defs.h | 36 ------------------ include/simdjson/lsx/stringparsing_defs.h | 37 ------------------- include/simdjson/ppc64/stringparsing_defs.h | 37 ------------------- .../simdjson/westmere/stringparsing_defs.h | 37 ------------------- 8 files changed, 270 deletions(-) diff --git a/include/simdjson/arm64/stringparsing_defs.h b/include/simdjson/arm64/stringparsing_defs.h index ec2e76359..72b8c8f08 100644 --- a/include/simdjson/arm64/stringparsing_defs.h +++ b/include/simdjson/arm64/stringparsing_defs.h @@ -18,10 +18,6 @@ struct backslash_and_quote { public: static constexpr uint32_t BYTES_PROCESSED = 32; simdjson_inline static backslash_and_quote copy_and_find(const uint8_t *src, uint8_t *dst); - ///////////// - /// TODO: This function is not used in the codebase. It is not clear if it is needed. - ///////////// - simdjson_inline static bool requires_escaping(const uint8_t *src, size_t len); simdjson_inline bool has_quote_first() { return ((bs_bits - 1) & quote_bits) != 0; } simdjson_inline bool has_backslash() { return bs_bits != 0; } @@ -32,38 +28,6 @@ public: uint32_t quote_bits; }; // struct backslash_and_quote -simdjson_inline bool backslash_and_quote::requires_escaping(const uint8_t *src, size_t len) { - // For short strings, we use a scalar approach - if(len < BYTES_PROCESSED) { - bool requires_escaping = false; - for(size_t i = 0; i < len; i++) { - uint8_t c = src[i]; - requires_escaping |= (c == '\\' || c == '"' || c < 32); - } - return requires_escaping; - } - // We use SIMD: - simd8 requires_escaping{}; - size_t j = 0; - for(; j + BYTES_PROCESSED <= len; j += BYTES_PROCESSED) { - simd8 v(src + j); - simd8 is_quote = (v == '"'); - simd8 is_backslash = (v == '\\'); - simd8 is_control = (v < 32); - requires_escaping |= is_backslash | is_quote | is_control; - } - if(j < len) { - // We virtually backtrack so we can load a full vector register - j = len - BYTES_PROCESSED; - simd8 v(src + j); - simd8 is_quote = (v == '"'); - simd8 is_backslash = (v == '\\'); - simd8 is_control = (v < 32); - requires_escaping |= is_backslash | is_quote | is_control; - } - return requires_escaping.any(); -} - simdjson_inline backslash_and_quote backslash_and_quote::copy_and_find(const uint8_t *src, uint8_t *dst) { // this can read up to 31 bytes beyond the buffer size, but we require // SIMDJSON_PADDING of padding diff --git a/include/simdjson/fallback/stringparsing_defs.h b/include/simdjson/fallback/stringparsing_defs.h index 732abe0a9..a7dedeb02 100644 --- a/include/simdjson/fallback/stringparsing_defs.h +++ b/include/simdjson/fallback/stringparsing_defs.h @@ -14,10 +14,6 @@ struct backslash_and_quote { public: static constexpr uint32_t BYTES_PROCESSED = 1; simdjson_inline static backslash_and_quote copy_and_find(const uint8_t *src, uint8_t *dst); - ///////////// - /// TODO: This function is not used in the codebase. It is not clear if it is needed. - ///////////// - simdjson_inline static bool requires_escaping(const uint8_t *src, size_t len); simdjson_inline bool has_quote_first() { return c == '"'; } simdjson_inline bool has_backslash() { return c == '\\'; } @@ -27,16 +23,6 @@ public: uint8_t c; }; // struct backslash_and_quote - -simdjson_inline bool backslash_and_quote::requires_escaping(const uint8_t *src, size_t len) { - bool requires_escaping = false; - for(size_t i = 0; i < len; i++) { - uint8_t c = src[i]; - requires_escaping |= (c == '\\' || c == '"' || c < 32); - } - return requires_escaping; -} - simdjson_inline backslash_and_quote backslash_and_quote::copy_and_find(const uint8_t *src, uint8_t *dst) { // store to dest unconditionally - we can overwrite the bits we don't like later dst[0] = src[0]; diff --git a/include/simdjson/haswell/stringparsing_defs.h b/include/simdjson/haswell/stringparsing_defs.h index 7c3d25e76..e8ce6e9fe 100644 --- a/include/simdjson/haswell/stringparsing_defs.h +++ b/include/simdjson/haswell/stringparsing_defs.h @@ -18,10 +18,6 @@ struct backslash_and_quote { public: static constexpr uint32_t BYTES_PROCESSED = 32; simdjson_inline static backslash_and_quote copy_and_find(const uint8_t *src, uint8_t *dst); - ///////////// - /// TODO: This function is not used in the codebase. It is not clear if it is needed. - ///////////// - simdjson_inline static bool requires_escaping(const uint8_t *src, size_t len); simdjson_inline bool has_quote_first() { return ((bs_bits - 1) & quote_bits) != 0; } simdjson_inline bool has_backslash() { return ((quote_bits - 1) & bs_bits) != 0; } @@ -32,38 +28,6 @@ public: uint32_t quote_bits; }; // struct backslash_and_quote -simdjson_inline bool backslash_and_quote::requires_escaping(const uint8_t *src, size_t len) { - // For short strings, we use a scalar approach - if(len < BYTES_PROCESSED) { - bool requires_escaping = false; - for(size_t i = 0; i < len; i++) { - uint8_t c = src[i]; - requires_escaping |= (c == '\\' || c == '"' || c < 32); - } - return requires_escaping; - } - // We use SIMD: - simd8 requires_escaping{}; - size_t j = 0; - for(; j + BYTES_PROCESSED <= len; j += BYTES_PROCESSED) { - simd8 v(src + j); - simd8 is_quote = (v == '"'); - simd8 is_backslash = (v == '\\'); - simd8 is_control = (v < 32); - requires_escaping |= is_backslash | is_quote | is_control; - } - if(j < len) { - // We virtually backtrack so we can load a full vector register - j = len - BYTES_PROCESSED; - simd8 v(src + j); - simd8 is_quote = (v == '"'); - simd8 is_backslash = (v == '\\'); - simd8 is_control = (v < 32); - requires_escaping |= is_backslash | is_quote | is_control; - } - return requires_escaping.any(); -} - simdjson_inline backslash_and_quote backslash_and_quote::copy_and_find(const uint8_t *src, uint8_t *dst) { // this can read up to 15 bytes beyond the buffer size, but we require // SIMDJSON_PADDING of padding diff --git a/include/simdjson/icelake/stringparsing_defs.h b/include/simdjson/icelake/stringparsing_defs.h index 6077e5f0e..13e4fef25 100644 --- a/include/simdjson/icelake/stringparsing_defs.h +++ b/include/simdjson/icelake/stringparsing_defs.h @@ -18,10 +18,6 @@ struct backslash_and_quote { public: static constexpr uint32_t BYTES_PROCESSED = 64; simdjson_inline static backslash_and_quote copy_and_find(const uint8_t *src, uint8_t *dst); - ///////////// - /// TODO: This function is not used in the codebase. It is not clear if it is needed. - ///////////// - simdjson_inline static bool requires_escaping(const uint8_t *src, size_t len); simdjson_inline bool has_quote_first() { return ((bs_bits - 1) & quote_bits) != 0; } simdjson_inline bool has_backslash() { return ((quote_bits - 1) & bs_bits) != 0; } @@ -32,39 +28,6 @@ public: uint64_t quote_bits; }; // struct backslash_and_quote - -simdjson_inline bool backslash_and_quote::requires_escaping(const uint8_t *src, size_t len) { - // For short strings, we use a scalar approach - if(len < BYTES_PROCESSED) { - bool requires_escaping = false; - for(size_t i = 0; i < len; i++) { - uint8_t c = src[i]; - requires_escaping |= (c == '\\' || c == '"' || c < 32); - } - return requires_escaping; - } - // We use SIMD: - simd8 requires_escaping{}; - size_t j = 0; - for(; j + BYTES_PROCESSED <= len; j += BYTES_PROCESSED) { - simd8 v(src + j); - simd8 is_quote = (v == '"'); - simd8 is_backslash = (v == '\\'); - simd8 is_control = (v < 32); - requires_escaping |= is_backslash | is_quote | is_control; - } - if(j < len) { - // We virtually backtrack so we can load a full vector register - j = len - BYTES_PROCESSED; - simd8 v(src + j); - simd8 is_quote = (v == '"'); - simd8 is_backslash = (v == '\\'); - simd8 is_control = (v < 32); - requires_escaping |= is_backslash | is_quote | is_control; - } - return requires_escaping.any(); -} - simdjson_inline backslash_and_quote backslash_and_quote::copy_and_find(const uint8_t *src, uint8_t *dst) { // this can read up to 15 bytes beyond the buffer size, but we require // SIMDJSON_PADDING of padding diff --git a/include/simdjson/lasx/stringparsing_defs.h b/include/simdjson/lasx/stringparsing_defs.h index c8bc1f9b6..97d109a04 100644 --- a/include/simdjson/lasx/stringparsing_defs.h +++ b/include/simdjson/lasx/stringparsing_defs.h @@ -18,10 +18,6 @@ struct backslash_and_quote { public: static constexpr uint32_t BYTES_PROCESSED = 32; simdjson_inline static backslash_and_quote copy_and_find(const uint8_t *src, uint8_t *dst); - ///////////// - /// TODO: This function is not used in the codebase. It is not clear if it is needed. - ///////////// - simdjson_inline static bool requires_escaping(const uint8_t *src, size_t len); simdjson_inline bool has_quote_first() { return ((bs_bits - 1) & quote_bits) != 0; } simdjson_inline bool has_backslash() { return bs_bits != 0; } @@ -32,38 +28,6 @@ public: uint32_t quote_bits; }; // struct backslash_and_quote -simdjson_inline bool backslash_and_quote::requires_escaping(const uint8_t *src, size_t len) { - // For short strings, we use a scalar approach - if(len < BYTES_PROCESSED) { - bool requires_escaping = false; - for(size_t i = 0; i < len; i++) { - uint8_t c = src[i]; - requires_escaping |= (c == '\\' || c == '"' || c < 32); - } - return requires_escaping; - } - // We use SIMD: - simd8 requires_escaping{}; - size_t j = 0; - for(; j + BYTES_PROCESSED <= len; j += BYTES_PROCESSED) { - simd8 v(src + j); - simd8 is_quote = (v == '"'); - simd8 is_backslash = (v == '\\'); - simd8 is_control = (v < 32); - requires_escaping |= is_backslash | is_quote | is_control; - } - if(j < len) { - // We virtually backtrack so we can load a full vector register - j = len - BYTES_PROCESSED; - simd8 v(src + j); - simd8 is_quote = (v == '"'); - simd8 is_backslash = (v == '\\'); - simd8 is_control = (v < 32); - requires_escaping |= is_backslash | is_quote | is_control; - } - return requires_escaping.any(); -} - simdjson_inline backslash_and_quote backslash_and_quote::copy_and_find(const uint8_t *src, uint8_t *dst) { // this can read up to 31 bytes beyond the buffer size, but we require // SIMDJSON_PADDING of padding diff --git a/include/simdjson/lsx/stringparsing_defs.h b/include/simdjson/lsx/stringparsing_defs.h index 59edc7647..df297332a 100644 --- a/include/simdjson/lsx/stringparsing_defs.h +++ b/include/simdjson/lsx/stringparsing_defs.h @@ -18,10 +18,6 @@ struct backslash_and_quote { public: static constexpr uint32_t BYTES_PROCESSED = 32; simdjson_inline static backslash_and_quote copy_and_find(const uint8_t *src, uint8_t *dst); - ///////////// - /// TODO: This function is not used in the codebase. It is not clear if it is needed. - ///////////// - simdjson_inline static bool requires_escaping(const uint8_t *src, size_t len); simdjson_inline bool has_quote_first() { return ((bs_bits - 1) & quote_bits) != 0; } simdjson_inline bool has_backslash() { return bs_bits != 0; } @@ -32,39 +28,6 @@ public: uint32_t quote_bits; }; // struct backslash_and_quote - -simdjson_inline bool backslash_and_quote::requires_escaping(const uint8_t *src, size_t len) { - // For short strings, we use a scalar approach - if(len < BYTES_PROCESSED) { - bool requires_escaping = false; - for(size_t i = 0; i < len; i++) { - uint8_t c = src[i]; - requires_escaping |= (c == '\\' || c == '"' || c < 32); - } - return requires_escaping; - } - // We use SIMD: - simd8 requires_escaping{}; - size_t j = 0; - for(; j + BYTES_PROCESSED <= len; j += BYTES_PROCESSED) { - simd8 v(src + j); - simd8 is_quote = (v == '"'); - simd8 is_backslash = (v == '\\'); - simd8 is_control = (v < 32); - requires_escaping |= is_backslash | is_quote | is_control; - } - if(j < len) { - // We virtually backtrack so we can load a full vector register - j = len - BYTES_PROCESSED; - simd8 v(src + j); - simd8 is_quote = (v == '"'); - simd8 is_backslash = (v == '\\'); - simd8 is_control = (v < 32); - requires_escaping |= is_backslash | is_quote | is_control; - } - return requires_escaping.any(); -} - simdjson_inline backslash_and_quote backslash_and_quote::copy_and_find(const uint8_t *src, uint8_t *dst) { // this can read up to 31 bytes beyond the buffer size, but we require // SIMDJSON_PADDING of padding diff --git a/include/simdjson/ppc64/stringparsing_defs.h b/include/simdjson/ppc64/stringparsing_defs.h index ee8945cf6..4f49aec9b 100644 --- a/include/simdjson/ppc64/stringparsing_defs.h +++ b/include/simdjson/ppc64/stringparsing_defs.h @@ -19,10 +19,6 @@ public: static constexpr uint32_t BYTES_PROCESSED = 32; simdjson_inline static backslash_and_quote copy_and_find(const uint8_t *src, uint8_t *dst); - ///////////// - /// TODO: This function is not used in the codebase. It is not clear if it is needed. - ///////////// - simdjson_inline static bool requires_escaping(const uint8_t *src, size_t len); simdjson_inline bool has_quote_first() { return ((bs_bits - 1) & quote_bits) != 0; @@ -39,39 +35,6 @@ public: uint32_t quote_bits; }; // struct backslash_and_quote - -simdjson_inline bool backslash_and_quote::requires_escaping(const uint8_t *src, size_t len) { - // For short strings, we use a scalar approach - if(len < BYTES_PROCESSED) { - bool requires_escaping = false; - for(size_t i = 0; i < len; i++) { - uint8_t c = src[i]; - requires_escaping |= (c == '\\' || c == '"' || c < 32); - } - return requires_escaping; - } - // We use SIMD: - simd8 requires_escaping{}; - size_t j = 0; - for(; j + BYTES_PROCESSED <= len; j += BYTES_PROCESSED) { - simd8 v(src + j); - simd8 is_quote = (v == '"'); - simd8 is_backslash = (v == '\\'); - simd8 is_control = (v < 32); - requires_escaping |= is_backslash | is_quote | is_control; - } - if(j < len) { - // We virtually backtrack so we can load a full vector register - j = len - BYTES_PROCESSED; - simd8 v(src + j); - simd8 is_quote = (v == '"'); - simd8 is_backslash = (v == '\\'); - simd8 is_control = (v < 32); - requires_escaping |= is_backslash | is_quote | is_control; - } - return requires_escaping.any(); -} - simdjson_inline backslash_and_quote backslash_and_quote::copy_and_find(const uint8_t *src, uint8_t *dst) { // this can read up to 31 bytes beyond the buffer size, but we require diff --git a/include/simdjson/westmere/stringparsing_defs.h b/include/simdjson/westmere/stringparsing_defs.h index 3c2dffdf7..1b576e7a5 100644 --- a/include/simdjson/westmere/stringparsing_defs.h +++ b/include/simdjson/westmere/stringparsing_defs.h @@ -15,10 +15,6 @@ struct backslash_and_quote { public: static constexpr uint32_t BYTES_PROCESSED = 32; simdjson_inline static backslash_and_quote copy_and_find(const uint8_t *src, uint8_t *dst); - ///////////// - /// TODO: This function is not used in the codebase. It is not clear if it is needed. - ///////////// - simdjson_inline static bool requires_escaping(const uint8_t *src, size_t len); simdjson_inline bool has_quote_first() { return ((bs_bits - 1) & quote_bits) != 0; } simdjson_inline bool has_backslash() { return bs_bits != 0; } @@ -29,39 +25,6 @@ public: uint32_t quote_bits; }; // struct backslash_and_quote - -simdjson_inline bool backslash_and_quote::requires_escaping(const uint8_t *src, size_t len) { - // For short strings, we use a scalar approach - if(len < BYTES_PROCESSED) { - bool requires_escaping = false; - for(size_t i = 0; i < len; i++) { - uint8_t c = src[i]; - requires_escaping |= (c == '\\' || c == '"' || c < 32); - } - return requires_escaping; - } - // We use SIMD: - simd8 requires_escaping{}; - size_t j = 0; - for(; j + BYTES_PROCESSED <= len; j += BYTES_PROCESSED) { - simd8 v(src + j); - simd8 is_quote = (v == '"'); - simd8 is_backslash = (v == '\\'); - simd8 is_control = (v < 32); - requires_escaping |= is_backslash | is_quote | is_control; - } - if(j < len) { - // We virtually backtrack so we can load a full vector register - j = len - BYTES_PROCESSED; - simd8 v(src + j); - simd8 is_quote = (v == '"'); - simd8 is_backslash = (v == '\\'); - simd8 is_control = (v < 32); - requires_escaping |= is_backslash | is_quote | is_control; - } - return requires_escaping.any(); -} - simdjson_inline backslash_and_quote backslash_and_quote::copy_and_find(const uint8_t *src, uint8_t *dst) { // this can read up to 31 bytes beyond the buffer size, but we require // SIMDJSON_PADDING of padding