1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-19 00:35:06 +00:00

AK+Spreadsheet+LibWeb: Remove JsonObject::get_or()

This removes JsonObject::get_or(), which is inefficient because it has
to copy the returned value. It was only used in a few cases, some of
which resulted in copying JsonObjects, which can become quite large.
This commit is contained in:
Max Wipfli 2021-06-28 12:40:04 +02:00 committed by Andreas Kling
parent e82611bb87
commit 9c8a2a5f69
4 changed files with 91 additions and 97 deletions

View file

@ -100,10 +100,14 @@ bool is_pseudo_property(PropertyID property_id)
json.value().as_object().for_each_member([&](auto& name, auto& value) {
VERIFY(value.is_object());
auto pseudo = value.as_object().get_or("pseudo", false);
VERIFY(pseudo.is_bool());
bool pseudo = false;
if (value.as_object().has("pseudo")) {
auto& pseudo_value = value.as_object().get("pseudo");
VERIFY(pseudo_value.is_bool());
pseudo = pseudo_value.as_bool();
}
if (pseudo.as_bool()) {
if (pseudo) {
auto member_generator = generator.fork();
member_generator.set("name:titlecase", title_casify(name));
member_generator.append(R"~~~(