Skip to content

Commit b6dbce3

Browse files
authored
Stop copying schema_location in SimpleOutput::Location every time (#473)
Fixes: #472 Signed-off-by: Juan Cruz Viotti <[email protected]>
1 parent 67015ae commit b6dbce3

File tree

3 files changed

+18
-21
lines changed

3 files changed

+18
-21
lines changed

src/compiler/include/sourcemeta/blaze/compiler_output.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,14 @@ class SOURCEMETA_BLAZE_COMPILER_EXPORT SimpleOutput {
104104
auto operator<(const Location &other) const noexcept -> bool {
105105
// Perform a lexicographical comparison
106106
return std::tie(this->instance_location, this->evaluate_path,
107-
this->schema_location) < std::tie(other.instance_location,
108-
other.evaluate_path,
109-
other.schema_location);
107+
this->schema_location.get()) <
108+
std::tie(other.instance_location, other.evaluate_path,
109+
other.schema_location.get());
110110
}
111111

112112
const sourcemeta::core::WeakPointer instance_location;
113113
const sourcemeta::core::WeakPointer evaluate_path;
114-
const std::string schema_location;
114+
const std::reference_wrapper<const std::string> schema_location;
115115
};
116116

117117
auto stacktrace(std::ostream &stream,

test/compiler/compiler_output_simple_test.cc

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,12 @@
2626
sourcemeta::core::to_pointer(expected_instance_location)}; \
2727
const auto evaluate_path{ \
2828
sourcemeta::core::to_pointer(expected_evaluate_path)}; \
29-
EXPECT_TRUE(output.annotations().contains( \
30-
{sourcemeta::core::to_weak_pointer(instance_location), \
31-
sourcemeta::core::to_weak_pointer(evaluate_path), \
32-
(expected_schema_location)})); \
33-
EXPECT_EQ(output.annotations() \
34-
.at({sourcemeta::core::to_weak_pointer(instance_location), \
35-
sourcemeta::core::to_weak_pointer(evaluate_path), \
36-
(expected_schema_location)}) \
37-
.size(), \
29+
const std::string schema_location{expected_schema_location}; \
30+
const sourcemeta::blaze::SimpleOutput::Location location{ \
31+
sourcemeta::core::to_weak_pointer(instance_location), \
32+
sourcemeta::core::to_weak_pointer(evaluate_path), schema_location}; \
33+
EXPECT_TRUE(output.annotations().contains(location)); \
34+
EXPECT_EQ(output.annotations().at(location).size(), \
3835
(expected_entry_count)); \
3936
}
4037

@@ -46,11 +43,11 @@
4643
sourcemeta::core::to_pointer(expected_instance_location)}; \
4744
const auto evaluate_path{ \
4845
sourcemeta::core::to_pointer(expected_evaluate_path)}; \
49-
EXPECT_EQ(output.annotations() \
50-
.at({sourcemeta::core::to_weak_pointer(instance_location), \
51-
sourcemeta::core::to_weak_pointer(evaluate_path), \
52-
(expected_schema_location)}) \
53-
.at(expected_entry_index), \
46+
const std::string schema_location{expected_schema_location}; \
47+
const sourcemeta::blaze::SimpleOutput::Location location{ \
48+
sourcemeta::core::to_weak_pointer(instance_location), \
49+
sourcemeta::core::to_weak_pointer(evaluate_path), schema_location}; \
50+
EXPECT_EQ(output.annotations().at(location).at(expected_entry_index), \
5451
(expected_value)); \
5552
}
5653

test/evaluator/annotationsuite.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ has_annotation(const sourcemeta::blaze::SimpleOutput &output,
3838
for (const auto &annotation : output.annotations()) {
3939
std::cerr << "Checking against annotations for instance location \""
4040
<< sourcemeta::core::to_string(annotation.first.instance_location)
41-
<< "\" and schema location \"" << annotation.first.schema_location
42-
<< "\"" << "\n";
41+
<< "\" and schema location \""
42+
<< annotation.first.schema_location.get() << "\"" << "\n";
4343

4444
if (annotation.first.instance_location != instance_location ||
45-
annotation.first.schema_location != schema_location) {
45+
annotation.first.schema_location.get() != schema_location) {
4646
continue;
4747
} else if (std::find(annotation.second.cbegin(), annotation.second.cend(),
4848
value) != annotation.second.cend()) {

0 commit comments

Comments
 (0)