From 275245dfefd73f5e4e81e46637ade03315408fb6 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 9 Sep 2012 11:01:22 +0200 Subject: Use new multi-index support from libcutl --- odb/pragma.cxx | 4 ++-- odb/pragma.hxx | 37 +++++++++++++++++++++++++------------ 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/odb/pragma.cxx b/odb/pragma.cxx index 9d97d2a..afdbd1d 100644 --- a/odb/pragma.cxx +++ b/odb/pragma.cxx @@ -2640,7 +2640,7 @@ handle_pragma_qualifier (cxx_lexer& l, string const& p) tt = l.next (tl, &tn); } - pair r ( + pair r ( virt_declarations_[scope].insert ( virt_declaration (loc, name, FIELD_DECL, type))); @@ -2676,7 +2676,7 @@ handle_pragma_qualifier (cxx_lexer& l, string const& p) if (i != virt_declarations_.end ()) { - virt_declaration_set::iterator j ( + virt_declaration_set::const_iterator j ( i->second.find (name_tokens.back ().literal, FIELD_DECL)); if (j != i->second.end ()) diff --git a/odb/pragma.hxx b/odb/pragma.hxx index f656079..efb80d8 100644 --- a/odb/pragma.hxx +++ b/odb/pragma.hxx @@ -13,6 +13,7 @@ #include #include +#include #include struct virt_declaration @@ -30,25 +31,37 @@ struct virt_declaration // different tree codes unequal. If that is too loose, then the // inserting code must do additional checks. // -struct virt_declaration_comparator +struct virt_declaration_set { - bool - operator () (virt_declaration const& x, virt_declaration const& y) const + typedef cutl::container::key key; + typedef std::map map; + typedef cutl::container::map_const_iterator const_iterator; + + std::pair + insert (const virt_declaration& v) { - return x.name < y.name || (x.name == y.name && x.tree_code < y.tree_code); - } -}; + std::pair r ( + map_.insert (map::value_type (key (v.name, v.tree_code), v))); -struct virt_declaration_set: - std::set -{ - typedef std::set base; + const_iterator i (r.first); - iterator + if (r.second) + r.first->first.assign (i->name, i->tree_code); + + return std::make_pair (i, r.second); + } + + const_iterator find (std::string const& name, int tree_code) const { - return base::find (virt_declaration (0, name, tree_code, 0)); + return map_.find (key (name, tree_code)); } + + const_iterator begin () const {return map_.begin ();} + const_iterator end () const {return map_.end ();} + +private: + map map_; }; // Map of scopes (e.g., class, namespace) to sets of virtual declarations. -- cgit v1.1