diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2023-05-21 20:26:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-21 20:26:24 +0200 |
commit | 7f0e6584f6e8f3e38e491494b0a7b24d37db4187 (patch) | |
tree | b76b2600e88d58fbd9163805298c7602ffdf38ea /searchcore/src/vespa/searchcore/proton/matching/blueprintbuilder.cpp | |
parent | 932b3cecfcc71408c9fe25bd23df992737e516a1 (diff) | |
parent | 79346d5d16c549347a15399505acaab96b4a5506 (diff) |
Merge pull request #27144 from vespa-engine/balder/reduce-number-of-allocationsv8.165.119
Balder/reduce number of allocations
Diffstat (limited to 'searchcore/src/vespa/searchcore/proton/matching/blueprintbuilder.cpp')
-rw-r--r-- | searchcore/src/vespa/searchcore/proton/matching/blueprintbuilder.cpp | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/matching/blueprintbuilder.cpp b/searchcore/src/vespa/searchcore/proton/matching/blueprintbuilder.cpp index eee2b7a7203..03e15830ac5 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/blueprintbuilder.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/blueprintbuilder.cpp @@ -30,21 +30,21 @@ struct Mixer { } Blueprint::UP mix(Blueprint::UP indexes) { - if (attributes.get() == 0) { - if (indexes.get() == 0) { + if ( ! attributes) { + if ( ! indexes) { return std::make_unique<EmptyBlueprint>(); } - return Blueprint::UP(std::move(indexes)); + return indexes; } - if (indexes.get() == 0) { + if ( ! indexes) { if (attributes->childCnt() == 1) { return attributes->removeChild(0); } else { - return Blueprint::UP(std::move(attributes)); + return std::move(attributes); } } - attributes->addChild(Blueprint::UP(std::move(indexes))); - return Blueprint::UP(std::move(attributes)); + attributes->addChild(std::move(indexes)); + return std::move(attributes); } }; @@ -88,6 +88,7 @@ private: void buildEquiv(ProtonEquiv &n) { double eqw = n.getWeight().percent(); FieldSpecBaseList specs; + specs.reserve(n.numFields()); for (size_t i = 0; i < n.numFields(); ++i) { specs.add(n.field(i).fieldSpec()); } @@ -123,9 +124,7 @@ private: assert(field.getFieldId() != search::fef::IllegalFieldId); assert(field.getHandle() != search::fef::IllegalHandle); if (field.attribute_field) { - FieldSpecList attrField; - attrField.add(field.fieldSpec()); - mixer.addAttribute(_context.getAttributes().createBlueprint(_requestContext, attrField, n)); + mixer.addAttribute(_context.getAttributes().createBlueprint(_requestContext, field.fieldSpec(), n)); } else { indexFields.add(field.fieldSpec()); } |