From 4131bb3dec1de913038309d99ef799a41d586e70 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Mon, 27 Jul 2015 11:32:10 -0700 Subject: [PATCH] feat(util/name_set): add to_name_set auxiliary function --- src/util/name_set.cpp | 7 +++++++ src/util/name_set.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/src/util/name_set.cpp b/src/util/name_set.cpp index 0ea3568ee..820d8f6e4 100644 --- a/src/util/name_set.cpp +++ b/src/util/name_set.cpp @@ -18,6 +18,13 @@ name mk_unique(name_set const & s, name const & suggestion) { } } +name_set to_name_set(buffer const & ns) { + name_set r; + for (name const & n : ns) + r.insert(n); + return r; +} + DECL_UDATA(name_set) static int mk_name_set(lua_State * L) { name_set r; diff --git a/src/util/name_set.h b/src/util/name_set.h index d1cfcc0af..e032f904a 100644 --- a/src/util/name_set.h +++ b/src/util/name_set.h @@ -13,6 +13,8 @@ typedef rb_tree name_set; /** \brief Make a name that does not occur in \c s, based on the given suggestion. */ name mk_unique(name_set const & s, name const & suggestion); +name_set to_name_set(buffer const & ns); + UDATA_DEFS_CORE(name_set) void open_name_set(lua_State * L); }