From 6e37f1dea1f50e8a2b3040325b604297dd3eb0e5 Mon Sep 17 00:00:00 2001 From: Daniel Wallin Date: Sat, 27 Mar 2004 18:35:15 +0000 Subject: [PATCH] removed LUABIND_DONT_COPY_STRINGS --- luabind/config.hpp | 6 ------ luabind/detail/class_rep.hpp | 6 ------ luabind/detail/link_compatibility.hpp | 12 ------------ luabind/function.hpp | 13 ------------- src/class.cpp | 33 +------------------------------- src/class_rep.cpp | 36 +---------------------------------- src/link_compatibility.cpp | 6 ------ 7 files changed, 2 insertions(+), 110 deletions(-) diff --git a/luabind/config.hpp b/luabind/config.hpp index 5b995f8..5b7e95e 100644 --- a/luabind/config.hpp +++ b/luabind/config.hpp @@ -84,12 +84,6 @@ namespace std // exceptions will still be catched when there's // no error checking. -// LUABIND_DONT_COPY_STRINGS -// define this if you only pass static constant strings to -// the def() methods. It will make luabind expect the -// strings to exist as long as the program is running. -// Luabind will not copy the strings in this case. - // LUABIND_NOT_THREADSAFE // this define will make luabind non-thread safe. That is, // it will rely on a static variable. You can still have diff --git a/luabind/detail/class_rep.hpp b/luabind/detail/class_rep.hpp index 494ceef..6c66b09 100644 --- a/luabind/detail/class_rep.hpp +++ b/luabind/detail/class_rep.hpp @@ -342,12 +342,6 @@ namespace luabind { namespace detail // for every overload std::map m_methods; -#ifndef LUABIND_DONT_COPY_STRINGS - // this is where the strings that the maps contains - // pointer to are kept. To make sure they are destructed. - std::vector m_strings; -#endif - // datamembers, some members may be readonly, and // only have a getter function std::map m_getters; diff --git a/luabind/detail/link_compatibility.hpp b/luabind/detail/link_compatibility.hpp index b4d81ff..6f0006a 100755 --- a/luabind/detail/link_compatibility.hpp +++ b/luabind/detail/link_compatibility.hpp @@ -28,12 +28,6 @@ namespace luabind { namespace detail { -#ifdef LUABIND_DONT_COPY_STRINGS - LUABIND_API void dont_copy_strings_defined_conflict(); -#else - LUABIND_API void dont_copy_strings_not_defined_conflict(); -#endif - #ifdef LUABIND_NOT_THREADSAFE LUABIND_API void not_threadsafe_defined_conflict(); #else @@ -48,12 +42,6 @@ namespace luabind { namespace detail inline void check_link_compatibility() { - #ifdef LUABIND_DONT_COPY_STRINGS - dont_copy_strings_defined_conflict(); - #else - dont_copy_strings_not_defined_conflict(); - #endif - #ifdef LUABIND_NOT_THREADSAFE not_threadsafe_defined_conflict(); #else diff --git a/luabind/function.hpp b/luabind/function.hpp index 5c6f465..ecc0f6c 100644 --- a/luabind/function.hpp +++ b/luabind/function.hpp @@ -91,11 +91,7 @@ namespace luabind struct function_rep { -#ifdef LUABIND_DONT_COPY_STRINGS function_rep(const char* name): m_name(name) {} -#else - function_rep(const std::string& name): m_name(name) {} -#endif void add_overload(const free_functions::overload_rep& o) { std::vector::iterator i = std::find(m_overloads.begin(), m_overloads.end(), o); @@ -113,19 +109,10 @@ namespace luabind const std::vector& overloads() const throw() { return m_overloads; } -#ifdef LUABIND_DONT_COPY_STRINGS const char* name() const { return m_name; } -#else - const char* name() const { return m_name.c_str(); } -#endif private: - -#ifdef LUABIND_DONT_COPY_STRINGS const char* m_name; -#else - std::string m_name; -#endif // this have to be write protected, since each time an overload is // added it has to be checked for existence. add_overload() should diff --git a/src/class.cpp b/src/class.cpp index 7d8a222..85183cc 100755 --- a/src/class.cpp +++ b/src/class.cpp @@ -67,22 +67,12 @@ namespace luabind { namespace detail { LUABIND_TYPE_INFO m_holder_type; LUABIND_TYPE_INFO m_const_holder_type; -#ifndef LUABIND_DONT_COPY_STRINGS - // the maps that contains char pointers points into - // this vector of strings. - mutable std::vector m_strings; -#endif scope m_scope; }; class_registration::class_registration(char const* name) { -#ifndef LUABIND_DONT_COPY_STRINGS - m_strings.push_back(detail::dup_string(name)); - m_name = m_strings.back(); -#else m_name = name; -#endif } void class_registration::register_(lua_State* L) const @@ -137,11 +127,6 @@ namespace luabind { namespace detail { // constructors m_constructor.swap(crep->m_constructor); -#ifndef LUABIND_DONT_COPY_STRINGS - assert(crep->m_strings.empty() && "Internal error"); - crep->m_strings.swap(m_strings); -#endif - crep->m_getters.swap(m_getters); crep->m_setters.swap(m_setters); @@ -280,12 +265,7 @@ namespace luabind { namespace detail { c.func = g; c.pointer_offset = 0; -#ifndef LUABIND_DONT_COPY_STRINGS - char* key = detail::dup_string(name); - m_registration->m_strings.push_back(key); -#else const char* key = name; -#endif m_registration->m_getters[key] = c; } @@ -310,12 +290,8 @@ namespace luabind { namespace detail { c.sig = get_sig_ptr; #endif -#ifndef LUABIND_DONT_COPY_STRINGS - char* key = detail::dup_string(name); - m_registration->m_strings.push_back(key); -#else + const char* key = name; -#endif m_registration->m_setters[key] = c; } @@ -331,15 +307,8 @@ namespace luabind { namespace detail { void class_base::add_method(const char* name, const detail::overload_rep& o) { -#ifdef LUABIND_DONT_COPY_STRINGS detail::method_rep& method = m_registration->m_methods[name]; method.name = name; -#else - m_registration->m_strings.push_back(detail::dup_string(name)); - detail::method_rep& method = m_registration->m_methods[ - m_registration->m_strings.back()]; - method.name = m_registration->m_strings.back(); -#endif method.add_overload(o); method.crep = 0; } diff --git a/src/class_rep.cpp b/src/class_rep.cpp index 2c12a08..f97edf2 100755 --- a/src/class_rep.cpp +++ b/src/class_rep.cpp @@ -114,12 +114,7 @@ luabind::detail::class_rep::class_rep(lua_State* L, const char* name) , m_const_holder_destructor(0) , m_operator_cache(0) { -#ifndef LUABIND_DONT_COPY_STRINGS - m_strings.push_back(detail::dup_string(name)); - m_name = m_strings.back(); -#else m_name = name; -#endif lua_newtable(L); m_table_ref = detail::ref(L); @@ -136,13 +131,6 @@ luabind::detail::class_rep::class_rep(lua_State* L, const char* name) luabind::detail::class_rep::~class_rep() { -#ifndef LUABIND_DONT_COPY_STRINGS - for (std::vector::iterator i = m_strings.begin(); - i != m_strings.end(); ++i) - { - delete[] *i; - } -#endif } // leaves object on lua stack @@ -794,12 +782,8 @@ void luabind::detail::class_rep::add_base_class(const luabind::detail::class_rep { // If we would assume that our base class will not be garbage collected until // this class is collected, we wouldn't had to copy these strings. -#ifndef LUABIND_DONT_COPY_STRINGS - m_strings.push_back(dup_string(i->first)); - method_rep& m = m_methods[m_strings.back()]; -#else method_rep& m = m_methods[i->first]; -#endif + m.name = i->first; m.crep = this; @@ -816,12 +800,7 @@ void luabind::detail::class_rep::add_base_class(const luabind::detail::class_rep for (std::map::const_iterator i = bcrep->m_getters.begin(); i != bcrep->m_getters.end(); ++i) { -#ifndef LUABIND_DONT_COPY_STRINGS - m_strings.push_back(dup_string(i->first)); - callback& m = m_getters[m_strings.back()]; -#else callback& m = m_getters[i->first]; -#endif m.pointer_offset = i->second.pointer_offset + binfo.pointer_offset; m.func = i->second.func; } @@ -830,15 +809,7 @@ void luabind::detail::class_rep::add_base_class(const luabind::detail::class_rep for (std::map::const_iterator i = bcrep->m_setters.begin(); i != bcrep->m_setters.end(); ++i) { -#ifndef LUABIND_DONT_COPY_STRINGS - // TODO: optimize this by not copying the string if it already exists in m_setters. - // This goes for m_getters, m_static_constants and m_functions too. Both here - // in add_base() and in the add_function(), add_getter() ... functions. - m_strings.push_back(dup_string(i->first)); - callback& m = m_setters[m_strings.back()]; -#else callback& m = m_setters[i->first]; -#endif m.pointer_offset = i->second.pointer_offset + binfo.pointer_offset; m.func = i->second.func; } @@ -847,12 +818,7 @@ void luabind::detail::class_rep::add_base_class(const luabind::detail::class_rep for (std::map::const_iterator i = bcrep->m_static_constants.begin(); i != bcrep->m_static_constants.end(); ++i) { -#ifndef LUABIND_DONT_COPY_STRINGS - m_strings.push_back(dup_string(i->first)); - int& v = m_static_constants[m_strings.back()]; -#else int& v = m_static_constants[i->first]; -#endif v = i->second; } diff --git a/src/link_compatibility.cpp b/src/link_compatibility.cpp index 9ceca1c..d22c68b 100755 --- a/src/link_compatibility.cpp +++ b/src/link_compatibility.cpp @@ -25,12 +25,6 @@ namespace luabind { namespace detail { -#ifdef LUABIND_DONT_COPY_STRINGS - void dont_copy_strings_defined_conflict() {} -#else - void dont_copy_strings_not_defined_conflict() {} -#endif - #ifdef LUABIND_NOT_THREADSAFE void not_threadsafe_defined_conflict() {} #else -- 2.11.4.GIT