Skip to content

Commit

Permalink
Do not store unused cast functions.
Browse files Browse the repository at this point in the history
In luabind::detail::class_base::m_registration::m_bases (where m_registration
is a luabind::detail::class_registration). m_bases was a mutable
std::vector<base_desc> (base_desc was a typedef on
std::pair<type_id, cast_function>) and is now simply a std::vector<type_id>.
  • Loading branch information
Oberon00 committed Jul 4, 2013
1 parent 8bc99e0 commit 204ef5d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions luabind/class.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ namespace luabind
type_id const& type, class_id id
, type_id const& wrapped_type, class_id wrapper_id);

void add_base(type_id const& base, cast_function cast);
void add_base(type_id const& base);

void add_member(registration* member);
void add_default_member(registration* member);
Expand Down Expand Up @@ -530,7 +530,7 @@ namespace luabind
template<class To>
void gen_base_info(detail::type_<To>)
{
add_base(typeid(To), detail::static_cast_<T, To>::execute);
add_base(typeid(To));
add_cast(
detail::registered_class<T>::id
, detail::registered_class<To>::id
Expand Down
11 changes: 5 additions & 6 deletions src/class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ namespace luabind { namespace detail {

mutable std::map<const char*, int, detail::ltstr> m_static_constants;

typedef std::pair<type_id, cast_function> base_desc;
mutable std::vector<base_desc> m_bases;
mutable std::vector<type_id> m_bases;

type_id m_type;
class_id m_id;
Expand Down Expand Up @@ -167,13 +166,13 @@ namespace luabind { namespace detail {
casts->insert(e.src, e.target, e.cast);
}

for (std::vector<base_desc>::iterator i = m_bases.begin();
for (std::vector<type_id>::iterator i = m_bases.begin();
i != m_bases.end(); ++i)
{
LUABIND_CHECK_STACK(L);

// the baseclass' class_rep structure
detail::class_rep* bcrep = registry->find_class(i->first);
detail::class_rep* bcrep = registry->find_class(*i);

crep->add_base_class(bcrep);

Expand Down Expand Up @@ -254,9 +253,9 @@ namespace luabind { namespace detail {
m_registration->m_wrapper_id = wrapper_id;
}

void class_base::add_base(type_id const& base, cast_function cast)
void class_base::add_base(type_id const& base)
{
m_registration->m_bases.push_back(std::make_pair(base, cast));
m_registration->m_bases.push_back(base);
}

void class_base::add_member(registration* member)
Expand Down

0 comments on commit 204ef5d

Please sign in to comment.