Skip to content

Commit 20f4bc7

Browse files
authored
Merge pull request #14 from casperisfine/backport-simd-error-message-fix
Backport simdjson error codes allocations fix.
2 parents e6c84ec + ad623dd commit 20f4bc7

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

ext/fast_jsonparser/simdjson.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2308,7 +2308,7 @@ using ErrorValues [[deprecated("This is an alias and will be removed, use error_
23082308
* @deprecated Error codes should be stored and returned as `error_code`, use `error_message()` instead.
23092309
*/
23102310
[[deprecated("Error codes should be stored and returned as `error_code`, use `error_message()` instead.")]]
2311-
inline const std::string &error_message(int error) noexcept;
2311+
inline const std::string error_message(int error) noexcept;
23122312
23132313
} // namespace simdjson
23142314
@@ -6367,7 +6367,7 @@ namespace internal {
63676367
// We store the error code so we can validate the error message is associated with the right code
63686368
struct error_code_info {
63696369
error_code code;
6370-
std::string message;
6370+
const char* message;
63716371
};
63726372
// These MUST match the codes in error_code. We check this constraint in basictests.
63736373
extern SIMDJSON_DLLIMPORTEXPORT const error_code_info error_codes[];
@@ -6376,10 +6376,10 @@ namespace internal {
63766376

63776377
inline const char *error_message(error_code error) noexcept {
63786378
// If you're using error_code, we're trusting you got it from the enum.
6379-
return internal::error_codes[int(error)].message.c_str();
6379+
return internal::error_codes[int(error)].message;
63806380
}
63816381

6382-
inline const std::string &error_message(int error) noexcept {
6382+
inline const std::string error_message(int error) noexcept {
63836383
if (error < 0 || error >= error_code::NUM_ERROR_CODES) {
63846384
return internal::error_codes[UNEXPECTED_ERROR].message;
63856385
}

0 commit comments

Comments
 (0)