[libcommuni] add upstream fix to parser performance bottleneck caused by encoding settings

Jan Kaluža jkaluza at fedoraproject.org
Mon Dec 3 15:04:25 UTC 2012


commit b415cd4e9b950494c5ee20b5b364b11fa80447a2
Author: Jan Kaluza <hanzz.k at gmail.com>
Date:   Mon Dec 3 16:04:16 2012 +0100

    add upstream fix to parser performance bottleneck caused by encoding settings

 libcommuni-encoding-perf.patch |   85 ++++++++++++++++++++++++++++++++++++++++
 libcommuni.spec                |    7 +++-
 2 files changed, 91 insertions(+), 1 deletions(-)
---
diff --git a/libcommuni-encoding-perf.patch b/libcommuni-encoding-perf.patch
new file mode 100644
index 0000000..96cf08f
--- /dev/null
+++ b/libcommuni-encoding-perf.patch
@@ -0,0 +1,85 @@
+diff --git a/src/ircdecoder.cpp b/src/ircdecoder.cpp
+index a770319..c23975f 100644
+--- a/src/ircdecoder.cpp
++++ b/src/ircdecoder.cpp
+@@ -32,6 +32,12 @@ COMMUNI_EXPORT void irc_set_codec_plugin(const QByteArray& key)
+     irc_plugin_key = key;
+ }
+ 
++COMMUNI_EXPORT bool irc_is_supported_encoding(const QByteArray& encoding)
++{
++    static QSet<QByteArray> codecs = QTextCodec::availableCodecs().toSet();
++    return codecs.contains(encoding);
++}
++
+ IrcDecoder::IrcDecoder()
+ {
+     d.fallback = QTextCodec::codecForName("UTF-8");
+@@ -48,8 +54,7 @@ QByteArray IrcDecoder::encoding() const
+ 
+ void IrcDecoder::setEncoding(const QByteArray& encoding)
+ {
+-    if (QTextCodec::availableCodecs().contains(encoding))
+-        d.fallback = QTextCodec::codecForName(encoding);
++    d.fallback = QTextCodec::codecForName(encoding);
+ }
+ 
+ QString IrcDecoder::decode(const QByteArray& data) const
+diff --git a/src/ircsession.cpp b/src/ircsession.cpp
+index 8d62c21..9e5c2fe 100644
+--- a/src/ircsession.cpp
++++ b/src/ircsession.cpp
+@@ -391,8 +391,8 @@ QByteArray IrcSession::encoding() const
+ void IrcSession::setEncoding(const QByteArray& encoding)
+ {
+     Q_D(IrcSession);
+-    if (!QTextCodec::availableCodecs().contains(encoding))
+-    {
++    extern bool irc_is_supported_encoding(const QByteArray& encoding); // ircmessagedecoder.cpp
++    if (!irc_is_supported_encoding(encoding)) {
+         qWarning() << "IrcSession::setEncoding(): unsupported encoding" << encoding;
+         return;
+     }
+diff --git a/tests/auto/ircdecoder/tst_ircdecoder.cpp b/tests/auto/ircdecoder/tst_ircdecoder.cpp
+index bbe4b1f..9ce17c6 100644
+--- a/tests/auto/ircdecoder/tst_ircdecoder.cpp
++++ b/tests/auto/ircdecoder/tst_ircdecoder.cpp
+@@ -18,9 +18,6 @@ class tst_IrcDecoder : public QObject
+ 
+ private slots:
+     void testDefaults();
+-
+-    void testEncoding_data();
+-    void testEncoding();
+ };
+ 
+ void tst_IrcDecoder::testDefaults()
+@@ -29,28 +26,6 @@ void tst_IrcDecoder::testDefaults()
+     QCOMPARE(decoder.encoding(), QByteArray("UTF-8"));
+ }
+ 
+-void tst_IrcDecoder::testEncoding_data()
+-{
+-    QTest::addColumn<QByteArray>("encoding");
+-    QTest::addColumn<QByteArray>("actual");
+-
+-    QTest::newRow("null") << QByteArray() << QByteArray("UTF-8");
+-    QTest::newRow("empty") << QByteArray("") << QByteArray("UTF-8");
+-    QTest::newRow("space") << QByteArray(" ") << QByteArray("UTF-8");
+-    QTest::newRow("invalid") << QByteArray("invalid") << QByteArray("UTF-8");
+-    foreach (const QByteArray& codec, QTextCodec::availableCodecs())
+-        QTest::newRow(codec) << codec << QTextCodec::codecForName(codec)->name();
+-}
+-
+-void tst_IrcDecoder::testEncoding()
+-{
+-    QFETCH(QByteArray, encoding);
+-    QFETCH(QByteArray, actual);
+-
+-    IrcDecoder decoder;
+-    decoder.setEncoding(encoding);
+-    QCOMPARE(decoder.encoding(), actual);
+-}
+ 
+ QTEST_MAIN(tst_IrcDecoder)
+ 
diff --git a/libcommuni.spec b/libcommuni.spec
index 58ab3e8..853afdc 100644
--- a/libcommuni.spec
+++ b/libcommuni.spec
@@ -2,7 +2,7 @@
 
 Name:           libcommuni
 Version:        1.2.0
-Release:        1%{?dist}
+Release:        2%{?dist}
 Summary:        Cross-platform IRC client library written with Qt 4
 Group:          System Environment/Libraries
 License:        LGPLv2+
@@ -10,6 +10,7 @@ URL:            http://communi.github.com
 # After updating source, update tardirname too.
 Source0:        http://github.com/communi/communi/tarball/v%{version}/communi-%{version}.tar.gz
 Source1:        communi.desktop
+Patch0:         libcommuni-encoding-perf.patch
 %if 0%{?rhel} > 0 && 0%{?rhel} <= 6
 BuildRequires:  qt4-devel
 %else
@@ -47,6 +48,7 @@ Communi is a cross-platform IRC client library written with Qt 4.
 
 %prep
 %setup -q -n %{tardirname}
+%patch0 -p1
 
 %build
 # examples don't build with older Qt versions.
@@ -106,6 +108,9 @@ desktop-file-install \
 %endif
 
 %changelog
+* Mon Dec 03 2012 Jan Kaluza <jkaluza at redhat.com> - 1.2.0-2
+- add upstream fix to parser performance bottleneck caused by encoding settings
+
 * Tue Oct 09 2012 Jan Kaluza <jkaluza at redhat.com> - 1.2.0-1
 - update to new upstream version 1.2.0
 


More information about the scm-commits mailing list