<html>
 <body>
  <div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
   <table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 solid;">
    <tr>
     <td>
      This is an automatically generated e-mail. To reply, visit:
      <a href="http://git.reviewboard.kde.org/r/109991/">http://git.reviewboard.kde.org/r/109991/</a>
     </td>
    </tr>
   </table>
   <br />










<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
 <p style="margin-top: 0;">On April 17th, 2013, 1:50 a.m. UTC, <b>Simeon Bird</b> wrote:</p>
 <blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
  



<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; border-collapse: collapse; margin: 2px padding: 2px;">
 <thead>
  <tr>
   <th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; font-size: 9pt; padding: 4px 8px; text-align: left;">
    <a href="http://git.reviewboard.kde.org/r/109991/diff/1/?file=138503#file138503line199" style="color: black; font-weight: bold; text-decoration: underline;">common/regexpcache.cpp</a>
    <span style="font-weight: normal;">

     (Diff revision 1)

    </span>
   </th>
  </tr>
 </thead>



 
 

 <tbody>

  <tr>
    <th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
    <th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">173</font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span class="n">QStringList</span> <span class="n">RegExpCache</span><span class="o">::</span><span class="n">splitString</span><span class="p">(</span> <span class="k">const</span> <span class="n">QString</span><span class="o">&</span> <span class="n">str</span> <span class="p">)</span></pre></td>
  </tr>

 </tbody>

</table>

  <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Why don't you use QString::split?</pre>
 </blockquote>



 <p>On April 18th, 2013, 4:55 p.m. UTC, <b>Lukasz Olender</b> wrote:</p>
 <blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
  <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">I've added comment.</pre>
 </blockquote>





 <p>On April 20th, 2013, 4:14 a.m. UTC, <b>Simeon Bird</b> wrote:</p>
 <blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
  <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Right...but I think you should use this function:

QStringList QString::split ( const QRegExp & rx, SplitBehavior behavior = KeepEmptyParts ) const

with a regex that means "split on any character NOT []\" 
(I can't remember offhand what that looks like in regex, but you can look it up).</pre>
 </blockquote>







</blockquote>
<pre style="margin-left: 1em; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">I'm not sure it's possible. Let's think just about "\x" rule, where 'x' is one of escaped characters. Split must be done after every char, except situation when last char was '\'. Also, split must be done between characters, not on some of them, because it will eat all characters we split on. This involves RegExp lookbehind rule and it's not supported by QRegExp class. Similar situation with "[...]". Here is few examples.

QString str = "nep\\omuk";
QStringList list;
list = str.split(QRegExp(""), QString::SkipEmptyParts);
// list: [ "n", "e", "p", "\", "o", "m", "u", "k" ]

list = str.split(QRegExp("."), QString::SkipEmptyParts);
// list: empty

list = str.split(QRegExp("[^o]"), QString::SkipEmptyParts);
// list: [ "o" ]

list = str.split(QRegExp(".{0}(?!\\\\)"), QString::SkipEmptyParts);
// list: [ "n", "e", "p\", "o", "m", "u", "k" ]

I might be wrong, maybe there is an another way to do it. If so, I'd be happy to solve it in more elegant way. AFAIK in Qt5 we have QRegularExpression with lookbehind included.</pre>
<br />




<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
 <p style="margin-top: 0;">On April 17th, 2013, 1:50 a.m. UTC, <b>Simeon Bird</b> wrote:</p>
 <blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
  <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Thanks for the patch! Please could you add a few comments on the design of the optimised regexp, why it is faster, how it works, and so on? It really helps us to review it faster. 

Also, could you please add the test cases you link to the nepomuk tests directory? If you like, submit a separate patch adding them, as a test for regexp speed and correctness would be useful in itself. 
</pre>
 </blockquote>




 <p>On April 18th, 2013, 4:55 p.m. UTC, <b>Lukasz Olender</b> wrote:</p>
 <blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
  <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Yes. I'll make an another patch when review of this will be finished. Thanks for response!</pre>
 </blockquote>





 <p>On April 20th, 2013, 4:14 a.m. UTC, <b>Simeon Bird</b> wrote:</p>
 <blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
  <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">You're welcome - actually though it would be really good if you could post the testcase patch now - I wanted to run the test for review of this patch.</pre>
 </blockquote>










</blockquote>

<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">To create tests I'll need to add some minor changes into current code (I'll add a method selection in constructor). There is also a need for a number of filenames to show performance gain or just corectness of this solution. Should I put a text file with filenames into new patch? Or maybe code which will get filenames directly from user's home directory?

If you're interested in checking solution, please go tohttp://www.sendspace.com/file/mkihdp, I posted sources of simple application and filenames I've created to test it. Everything is ready for looking (except there is an old version of RegExpCache class without your reviews, but it's also working).</pre>
<br />


<p>- Lukasz</p>


<br />
<p>On April 18th, 2013, 4:27 p.m. UTC, Lukasz Olender wrote:</p>








<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" style="background-image: url('http://git.reviewboard.kde.org/static/rb/images/review_request_box_top_bg.ab6f3b1072c9.png'); background-position: left top; background-repeat: repeat-x; border: 1px black solid;">
 <tr>
  <td>

<div>Review request for Nepomuk and Vishesh Handa.</div>
<div>By Lukasz Olender.</div>


<p style="color: grey;"><i>Updated April 18, 2013, 4:27 p.m.</i></p>






<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
 <table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
 <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">It's related with https://bugs.kde.org/show_bug.cgi?id=303654. 
P.S. I accidentally deleted author's and license info in patch. Isolated performance tests are also uploaded to http://www.sendspace.com/file/mkihdp (previous link not always work). It's my first patch.</pre>
  </td>
 </tr>
</table>




<div style="margin-top: 1.5em;">
 <b style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Bugs: </b>


 <a href="http://bugs.kde.org/show_bug.cgi?id=303654">303654</a>


</div>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">

 <li>common/regexpcache.h <span style="color: grey">(d89f968)</span></li>

 <li>common/regexpcache.cpp <span style="color: grey">(df45277)</span></li>

</ul>

<p><a href="http://git.reviewboard.kde.org/r/109991/diff/" style="margin-left: 3em;">View Diff</a></p>







  </td>
 </tr>
</table>








  </div>
 </body>
</html>