From f18e41b73456f3996586a7d7b426ff2eacb6b40a Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Mon, 8 Jan 2007 11:01:26 +0000 Subject: [PATCH] performance fix/cleanup. * LyXKeySym.h: replace global operator==() with pure virtual method. * QLyXKeySym: new operator==() method. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16598 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/LyXKeySym.h | 9 +++------ src/frontends/qt4/QLyXKeySym.C | 9 ++++----- src/frontends/qt4/QLyXKeySym.h | 5 +++++ 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/frontends/LyXKeySym.h b/src/frontends/LyXKeySym.h index 618082ee2c..fe30a1c769 100644 --- a/src/frontends/LyXKeySym.h +++ b/src/frontends/LyXKeySym.h @@ -35,6 +35,9 @@ public: virtual ~LyXKeySym() {} + /// + virtual bool operator==(LyXKeySym const& ks) const = 0; + /// Initialize with the name of a key. F. ex. "space" or "a" virtual void init(std::string const & symbolname) = 0; @@ -64,12 +67,6 @@ public: }; -/** - * We need to be able to equality compare these for the - * sake of the keymap business. - */ -bool operator==(LyXKeySym const & k1, LyXKeySym const & k2); - typedef boost::shared_ptr LyXKeySymPtr; diff --git a/src/frontends/qt4/QLyXKeySym.C b/src/frontends/qt4/QLyXKeySym.C index c6ef16a2ad..665be121b0 100644 --- a/src/frontends/qt4/QLyXKeySym.C +++ b/src/frontends/qt4/QLyXKeySym.C @@ -241,18 +241,17 @@ bool QLyXKeySym::isText() const } -bool operator==(LyXKeySym const & k1, LyXKeySym const & k2) +bool QLyXKeySym::operator==(LyXKeySym const & ks) const { - QLyXKeySym const & q1(static_cast(k1)); - QLyXKeySym const & q2(static_cast(k2)); + QLyXKeySym const & qks = static_cast(ks); // we do not have enough info for a fair comparison, so return // false. This works out OK because unknown text from Qt will // get inserted anyway after the isText() check - if (q1.key() == Qt::Key_unknown || q2.key() == Qt::Key_unknown) + if (key_ == Qt::Key_unknown || qks.key_ == Qt::Key_unknown) return false; - return q1.key() == q2.key(); + return key_ == qks.key_; } diff --git a/src/frontends/qt4/QLyXKeySym.h b/src/frontends/qt4/QLyXKeySym.h index 9fc85fc3ee..45a607fc8e 100644 --- a/src/frontends/qt4/QLyXKeySym.h +++ b/src/frontends/qt4/QLyXKeySym.h @@ -34,6 +34,11 @@ public: virtual ~QLyXKeySym() {} + /// . + /// inlined out because of profiling results under linux when + /// opening a document. + inline bool operator==(LyXKeySym const& ks) const; + /// delayed constructor void set(QKeyEvent * ev); -- 2.39.2