From e65f28e61a30a337915057671c094b688c25e003 Mon Sep 17 00:00:00 2001 From: Herman Semenov Date: Thu, 18 Aug 2022 21:16:46 +0300 Subject: [PATCH] Fixed if condition, Win64 _fseeki64, trivial constructors C++11 (#1883) --- include/simdjson/dom/parser-inl.h | 8 +++++++- include/simdjson/padded_string-inl.h | 10 ++++++++-- src/generic/stage1/json_scanner.h | 2 +- src/generic/stage1/utf8_lookup4_algorithm.h | 2 +- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/include/simdjson/dom/parser-inl.h b/include/simdjson/dom/parser-inl.h index c74f97f4c..580847cfd 100644 --- a/include/simdjson/dom/parser-inl.h +++ b/include/simdjson/dom/parser-inl.h @@ -42,7 +42,13 @@ inline simdjson_result parser::read_file(const std::string &path) noexce } // Get the file size - if(std::fseek(fp, 0, SEEK_END) < 0) { + int ret; +#if defined(SIMDJSON_VISUAL_STUDIO) && !SIMDJSON_IS_32BITS + ret = _fseeki64(fp, 0, SEEK_END); +#else + ret = std::fseek(fp, 0, SEEK_END); +#endif // _WIN64 + if(ret < 0) { std::fclose(fp); return IO_ERROR; } diff --git a/include/simdjson/padded_string-inl.h b/include/simdjson/padded_string-inl.h index 06f6ce66d..434d8e307 100644 --- a/include/simdjson/padded_string-inl.h +++ b/include/simdjson/padded_string-inl.h @@ -45,7 +45,7 @@ inline char *allocate_padded_buffer(size_t length) noexcept { } // namespace internal -inline padded_string::padded_string() noexcept {} +inline padded_string::padded_string() noexcept = default; inline padded_string::padded_string(size_t length) noexcept : viable_size(length), data_ptr(internal::allocate_padded_buffer(length)) { } @@ -127,7 +127,13 @@ inline simdjson_result padded_string::load(std::string_view filen } // Get the file size - if(std::fseek(fp, 0, SEEK_END) < 0) { + int ret; +#if defined(SIMDJSON_VISUAL_STUDIO) && !SIMDJSON_IS_32BITS + ret = _fseeki64(fp, 0, SEEK_END); +#else + ret = std::fseek(fp, 0, SEEK_END); +#endif // _WIN64 + if(ret < 0) { std::fclose(fp); return IO_ERROR; } diff --git a/src/generic/stage1/json_scanner.h b/src/generic/stage1/json_scanner.h index 9958e4823..7640ff6f6 100644 --- a/src/generic/stage1/json_scanner.h +++ b/src/generic/stage1/json_scanner.h @@ -96,7 +96,7 @@ private: */ class json_scanner { public: - json_scanner() {} + json_scanner() = default; simdjson_inline json_block next(const simd::simd8x64& in); // Returns either UNCLOSED_STRING or SUCCESS simdjson_inline error_code finish(); diff --git a/src/generic/stage1/utf8_lookup4_algorithm.h b/src/generic/stage1/utf8_lookup4_algorithm.h index bb549d243..083474d02 100644 --- a/src/generic/stage1/utf8_lookup4_algorithm.h +++ b/src/generic/stage1/utf8_lookup4_algorithm.h @@ -173,7 +173,7 @@ using namespace simd; "We support one, two or four chunks per 64-byte block."); if(simd8x64::NUM_CHUNKS == 1) { this->check_utf8_bytes(input.chunks[0], this->prev_input_block); - } if(simd8x64::NUM_CHUNKS == 2) { + } else if(simd8x64::NUM_CHUNKS == 2) { this->check_utf8_bytes(input.chunks[0], this->prev_input_block); this->check_utf8_bytes(input.chunks[1], input.chunks[0]); } else if(simd8x64::NUM_CHUNKS == 4) {