chore: give up on InlinedVector due to spurious warnings with optional (#3765)

This commit is contained in:
Roman Gershman 2024-09-23 11:34:39 +03:00 committed by GitHub
parent 7df95dfb6e
commit 9c49aee43d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 10 deletions

View file

@ -4,8 +4,6 @@
#pragma once
#include <absl/container/inlined_vector.h>
#include <string_view>
#include <utility>
#include <variant>
@ -98,7 +96,7 @@ template <typename T> class JsonCallbackResult {
JsonCallbackResult() {
}
explicit JsonCallbackResult(CallbackResultOptions options) : options_(options) {
explicit JsonCallbackResult(CallbackResultOptions options) : options_(std::move(options)) {
}
void AddValue(T value) {
@ -119,8 +117,8 @@ template <typename T> class JsonCallbackResult {
return result_.front();
}
const absl::InlinedVector<T, 2>& AsV2() const {
return std::move(result_);
const auto& AsV2() const {
return result_;
}
bool Empty() const {
@ -144,7 +142,7 @@ template <typename T> class JsonCallbackResult {
}
private:
absl::InlinedVector<T, 2> result_;
std::vector<T> result_;
CallbackResultOptions options_{kDefaultJsonPathType};
};

View file

@ -593,13 +593,9 @@ OpResult<JsonCallbackResult<T>> JsonEvaluateOperation(const OpArgs& op_args, std
EvaluateOperationOptions options = {}) {
OpResult<JsonType*> result = GetJson(op_args, key);
if (options.return_nil_if_key_not_found && result == OpStatus::KEY_NOTFOUND) {
// GCC 13.1 throws spurious warnings around this code.
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
return JsonCallbackResult<T>{
{JsonPathType::kLegacy, options.cb_result_options.saving_order,
CallbackResultOptions::OnEmpty::kSendNil}}; // set legacy mode to return nil
#pragma GCC diagnostic pop
}
RETURN_ON_BAD_STATUS(result);