From 06f3abe26dd1f6a410e5270b94696a9f40c6a2c6 Mon Sep 17 00:00:00 2001 From: vitaut Date: Tue, 12 Jan 2016 06:37:39 -0800 Subject: [PATCH] Return early from ArgMap::find --- format.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/format.h b/format.h index 2f15bbb4..76f17952 100644 --- a/format.h +++ b/format.h @@ -1681,13 +1681,13 @@ class ArgMap { FMT_API void init(const ArgList &args); const internal::Arg* find(const fmt::BasicStringRef &name) const { - typename MapType::const_iterator it = map_.begin(); - // the list is unsorted, so just return the first matching name. - for (; it != map_.end(); ++it) { + // The list is unsorted, so just return the first matching name. + for (typename MapType::const_iterator it = map_.begin(), end = map_.end(); + it != end; ++it) { if (it->first == name) - break; + return &it->second; } - return it != map_.end() ? &it->second : 0; + return 0; } };