<p>Well, yeah I don't like inefficient code when it can easily be improved in that aspect.  OTOH, I prefer easy to read/maintain code.</p>
<p>And I'll have to check again, maybe I was tired, but I found your code oddly hard to follow, and tricky to fix the issues I found. At the time I found that working on path components directly made everything simpler at many level.</p>
<p>And for the matter of otherwise useful reusable functions, yes, but for example I think I remember one bug is that the longest common substring is <em>not</em> necessarily what you want here, like in <em>/a/b/c/d/longilename</em> vs. <em>/z/b/c/y/longfilename</em>: <em>longfilename</em> is obviously the longest substring, but you actually want <em>/b/c/</em> -- so IIRC your code will just not shorten this because it'll find <em>longfilename</em> as the substring, but will rightly ignore it because it the basename.  So to fix this the function should be updated to find the longest substring <em>surrounded by separators</em>, becoming a lot less useful for other callers.</p>
<p>However yes, if you can fix the issues I'll try and give it a new shot and propose some changes instead of a totally different approach.</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/geany/geany/pull/1445#issuecomment-371999526">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABDrJ4TrPwxHPhWPeJMaKz08zQFJTCc8ks5tc0qpgaJpZM4MnYrc">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/ABDrJzCNQAGW2OE29O01Wb4efNWTAvsqks5tc0qpgaJpZM4MnYrc.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
  <link itemprop="url" href="https://github.com/geany/geany/pull/1445#issuecomment-371999526"></link>
  <meta itemprop="name" content="View Pull Request"></meta>
</div>
<meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>

<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/geany/geany","title":"geany/geany","subtitle":"GitHub repository","main_image_url":"https://cloud.githubusercontent.com/assets/143418/17495839/a5054eac-5d88-11e6-95fc-7290892c7bb5.png","avatar_image_url":"https://cloud.githubusercontent.com/assets/143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png","action":{"name":"Open in GitHub","url":"https://github.com/geany/geany"}},"updates":{"snippets":[{"icon":"PERSON","message":"@b4n in #1445: Well, yeah I don't like inefficient code when it can easily be improved in that aspect.  OTOH, I prefer easy to read/maintain code.\r\n\r\nAnd I'll have to check again, maybe I was tired, but I found your code oddly hard to follow, and tricky to fix the issues I found. At the time I found that working on path components directly made everything simpler at many level.\r\n\r\nAnd for the matter of otherwise useful reusable functions, yes, but for example I think I remember one bug is that the longest common substring is *not* necessarily what you want here, like in */a/b/c/d/longilename* vs. */z/b/c/y/longfilename*: *longfilename* is obviously the longest substring, but you actually want */b/c/* -- so IIRC your code will just not shorten this because it'll find *longfilename* as the substring, but will rightly ignore it because it the basename.  So to fix this the function should be updated to find the longest substring *surrounded by separators*, becoming a lot less useful for other callers.\r\n\r\nHowever yes, if you can fix the issues I'll try and give it a new shot and propose some changes instead of a totally different approach."}],"action":{"name":"View Pull Request","url":"https://github.com/geany/geany/pull/1445#issuecomment-371999526"}}}</script>