]> git.pld-linux.org Git - packages/akonadi.git/blob - 0028-Extend-imapparser-benchmark-and-keep-static-data-aro.patch
boost rebuild
[packages/akonadi.git] / 0028-Extend-imapparser-benchmark-and-keep-static-data-aro.patch
1 From da5751c7b1589d2ea5800a3cf96dfc93b23b9783 Mon Sep 17 00:00:00 2001
2 From: Milian Wolff <mail@milianw.de>
3 Date: Tue, 9 Dec 2014 14:35:04 +0100
4 Subject: [PATCH 28/30] Extend imapparser benchmark and keep static data
5  around.
6
7 This gets rid of some temporary allocations and thus speeds up
8 the whole process a bit.
9
10 REVIEW: 121406
11 ---
12  libs/imapparser.cpp                |  5 +++--
13  libs/tests/imapparserbenchmark.cpp | 22 ++++++++++++++++++++++
14  2 files changed, 25 insertions(+), 2 deletions(-)
15
16 diff --git a/libs/imapparser.cpp b/libs/imapparser.cpp
17 index 9b437e2..6f9f592 100644
18 --- a/libs/imapparser.cpp
19 +++ b/libs/imapparser.cpp
20 @@ -364,7 +364,8 @@ int ImapParser::parseNumber( const QByteArray &data, qint64 &result, bool *ok, i
21  QByteArray ImapParser::quote( const QByteArray &data )
22  {
23    if ( data.isEmpty() ) {
24 -    return QByteArray( "\"\"" );
25 +    static const QByteArray empty( "\"\"" );
26 +    return empty;
27    }
28  
29    const int inputLength = data.length();
30 @@ -499,7 +500,7 @@ int ImapParser::parseDateTime( const QByteArray &data, QDateTime &dateTime, int
31    }
32  
33    pos += 3;
34 -  const QByteArray shortMonthNames( "janfebmaraprmayjunjulaugsepoctnovdec" );
35 +  static const QByteArray shortMonthNames( "janfebmaraprmayjunjulaugsepoctnovdec" );
36    int month = shortMonthNames.indexOf( data.mid( pos, 3 ).toLower() );
37    if ( month == -1 ) {
38      return start;
39 diff --git a/libs/tests/imapparserbenchmark.cpp b/libs/tests/imapparserbenchmark.cpp
40 index 17dac66..fd4335c 100644
41 --- a/libs/tests/imapparserbenchmark.cpp
42 +++ b/libs/tests/imapparserbenchmark.cpp
43 @@ -94,6 +94,28 @@ class ImapParserBenchmark : public QObject
44          ImapParser::parseParenthesizedList( data, result, 0 );
45        }
46      }
47 +
48 +    void parseNumber()
49 +    {
50 +      QByteArray data( "123456" );
51 +      qint64 result;
52 +      bool ok = false;
53 +      QBENCHMARK {
54 +        ImapParser::parseNumber( data, result, &ok );
55 +      }
56 +      QVERIFY(ok);
57 +      QCOMPARE(result, qint64(123456));
58 +    }
59 +
60 +    void parseDateTime()
61 +    {
62 +      QByteArray data( "28-May-2006 01:03:35 +0000" );
63 +      QDateTime result;
64 +      QBENCHMARK {
65 +        ImapParser::parseDateTime( data, result );
66 +      }
67 +      QCOMPARE(result.toString( QString::fromUtf8( "dd-MMM-yyyy hh:mm:ss +0000" ) ), QString::fromUtf8( data ));
68 +    }
69  };
70  
71  #include "imapparserbenchmark.moc"
72 -- 
73 2.1.0
74
This page took 0.054691 seconds and 3 git commands to generate.