From e3ef6b3384631e78dd7249f52455c45ea7d73552 Mon Sep 17 00:00:00 2001 From: Artem Pavlenko Date: Wed, 13 Apr 2005 20:20:46 +0000 Subject: [PATCH] return const& from attribute_by_name --- include/comparison.hh | 8 ++++---- include/feature.hh | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/include/comparison.hh b/include/comparison.hh index c9facf3b1..10676e0fc 100644 --- a/include/comparison.hh +++ b/include/comparison.hh @@ -54,7 +54,7 @@ namespace mapnik bool pass(const Feature& feature) const { - attribute attr=feature.attribute_by_name(name_); + const attribute& attr=feature.attribute_by_name(name_); bool result=false; try { @@ -95,7 +95,7 @@ namespace mapnik bool pass(const Feature& feature) const { - attribute attr=feature.attribute_by_name(name_); + const attribute& attr=feature.attribute_by_name(name_); bool result=false; try { @@ -134,7 +134,7 @@ namespace mapnik bool pass(const Feature& feature) const { - attribute attr=feature.attribute_by_name(name_); + const attribute& attr=feature.attribute_by_name(name_); bool result=false; try { @@ -178,7 +178,7 @@ namespace mapnik bool pass(const Feature& feature) const { - attribute attr=feature.attribute_by_name(name_); + const attribute& attr=feature.attribute_by_name(name_); bool result=false; try { diff --git a/include/feature.hh b/include/feature.hh index 93c5ea5c1..93a65ed9f 100644 --- a/include/feature.hh +++ b/include/feature.hh @@ -92,12 +92,13 @@ namespace mapnik attr_.insert(std::make_pair(name,attribute(value))); } - attribute attribute_by_name(const std::string& name) const + const attribute& attribute_by_name(const std::string& name) const { typename attributes::const_iterator pos=attr_.find(name); if (pos!=attr_.end()) return pos->second; - return attribute(); + static attribute empty; + return empty; } const attributes& get_attributes() const