Edwin Leuven wrote:
i've noticed that breaking a paragraph is much quicker than "unbreaking"
it (cursor at beginning of par and then backspace)
i think that this has always been the case, but i was wondering whether
there is something that can be done about it? (i guess i am looking at
you abdel ;-)
This is fixed now!
Abdel.
Author: younes
Date: Sat Jan 13 10:31:47 2007
New Revision: 16662
URL: http://www.lyx.org/trac/changeset/16662
Log:
Messages:
- cache_: new cache for gettext translated string.
Modified:
lyx-devel/trunk/src/messages.C
lyx-devel/trunk/src/messages.h
Modified: lyx-devel/trunk/src/messages.C
URL: http://www.lyx.org/trac/file/lyx-devel/trunk/src/messages.C?rev=16662
==============================================================================
--- lyx-devel/trunk/src/messages.C (original)
+++ lyx-devel/trunk/src/messages.C Sat Jan 13 10:31:47 2007
@@ -21,16 +21,16 @@
#include <boost/regex.hpp>
#include <cerrno>
-
+#include <map>
+
+using std::endl;
+using std::string;
namespace lyx {
using support::package;
using support::getEnv;
using support::setEnv;
-
-using std::string;
-using std::endl;
static boost::regex const reg("^([^\\[]*)\\[\\[[^\\]]*\\]\\]$");
@@ -114,10 +114,17 @@
~Pimpl() {}
- docstring const get(string const & m) const
- {
+ docstring const & get(string const & m) const
+ {
+ static docstring empty_string;
if (m.empty())
- return from_ascii(m);
+ return empty_string;
+
+ // Look for the translated string in the cache.
+ CacheType::iterator it = cache_.find(m);
+ if (it != cache_.end())
+ return it->second;
+ // The string was not found, use gettext to generate it:
// In this order, see support/filetools.C:
string lang = getEnv("LC_ALL");
@@ -206,11 +213,18 @@
setlocale(LC_MESSAGES, lang.c_str());
#endif
setlocale(LC_CTYPE, oldCTYPE.c_str());
- return translated;
+
+ it = cache_.insert(std::make_pair(m, translated)).first;
+ return it->second;
}
private:
///
string lang_;
+ typedef std::map<string, docstring> CacheType;
+ /// Internal cache for gettext translated strings.
+ /// This is needed for performance reason within \c updateLabels()
+ /// under Windows.
+ mutable CacheType cache_;
};
#endif
@@ -250,7 +264,7 @@
{}
-docstring const Messages::get(string const & msg) const
+docstring const & Messages::get(string const & msg) const
{
return pimpl_->get(msg);
}
Modified: lyx-devel/trunk/src/messages.h
URL: http://www.lyx.org/trac/file/lyx-devel/trunk/src/messages.h?rev=16662
==============================================================================
--- lyx-devel/trunk/src/messages.h (original)
+++ lyx-devel/trunk/src/messages.h Sat Jan 13 10:31:47 2007
@@ -29,7 +29,7 @@
///
~Messages();
///
- docstring const get(std::string const & msg) const;
+ docstring const & get(std::string const & msg) const;
private:
class Pimpl;
boost::scoped_ptr<Pimpl> pimpl_;