Author: aschnell Date: Sat Jan 10 12:45:36 2009 New Revision: 54531 URL: http://svn.opensuse.org/viewcvs/yast?rev=54531&view=rev Log: - typedef and use YCPMap::key_compare Modified: trunk/core/libycp/src/YCPMap.cc trunk/core/libycp/src/include/ycp/YCPMap.h Modified: trunk/core/libycp/src/YCPMap.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/YCPMap.cc?rev=54531&r1=54530&r2=54531&view=diff ============================================================================== --- trunk/core/libycp/src/YCPMap.cc (original) +++ trunk/core/libycp/src/YCPMap.cc Sat Jan 10 12:45:36 2009 @@ -58,19 +58,21 @@ return; } - // note: 'stl_map[key] = value' would create a temporary object using the - // default constructor for YCPValue. + // Note: 'stl_map[key] = value' would create a temporary object using the + // default constructor for YCPValue. See Scott Meyers, Effective STL, Item + // 24. YCPMap::iterator pos = stl_map.lower_bound(key); - if (pos == stl_map.end() || ycp_not_equal_to()(pos->first, key)) + if (pos != stl_map.end() && !YCPMap::key_compare()(key, pos->first)) { - // pos is just a hint but can avoid a second search through the map - stl_map.insert(pos, YCPMap::value_type(key, value)); + pos->second = value; } else { - pos->second = value; + // pos is just a hint but can avoid a second search through the map + stl_map.insert(pos, YCPMap::value_type(key, value)); } + } Modified: trunk/core/libycp/src/include/ycp/YCPMap.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/include/ycp/YCPMap.h?rev=54531&r1=54530&r2=54531&view=diff ============================================================================== --- trunk/core/libycp/src/include/ycp/YCPMap.h (original) +++ trunk/core/libycp/src/include/ycp/YCPMap.h Sat Jan 10 12:45:36 2009 @@ -52,6 +52,7 @@ typedef YCPValueYCPValueMap::iterator iterator; typedef YCPValueYCPValueMap::const_iterator const_iterator; typedef YCPValueYCPValueMap::value_type value_type; + typedef YCPValueYCPValueMap::key_compare key_compare; friend class YCPMap; @@ -186,6 +187,7 @@ typedef YCPMapRep::iterator iterator; typedef YCPMapRep::const_iterator const_iterator; typedef YCPMapRep::value_type value_type; + typedef YCPMapRep::key_compare key_compare; YCPMap() : YCPValue(new YCPMapRep()) {} YCPMap(bytecodeistream & str); -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org