<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Poor performance removing blank lines]]></title><description><![CDATA[<p dir="auto">With a 600,000 line .I preprocessor file:</p>
<p dir="auto">Edit→Line Operations→Remove Empty Lines?  &gt;3 minutes</p>
<p dir="auto">Ctrl+A→TextFX→TextFX Edit→Delete Blank Lines?  1 second</p>
<p dir="auto">:/</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/21060/poor-performance-removing-blank-lines</link><generator>RSS for Node</generator><lastBuildDate>Tue, 17 Nov 2026 07:58:30 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/21060.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 21 Apr 2021 18:36:05 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Poor performance removing blank lines on Fri, 23 Apr 2021 16:38:56 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/ekopalypse" aria-label="Profile: Ekopalypse">@<bdi>Ekopalypse</bdi></a></p>
<p dir="auto">Well, I <em>guess</em>.<br />
Sometimes there’s an art to data creation, though.<br />
For instance, perhaps really long lines impact how fast something will run.<br />
Perhaps the ratio of empty to non-empty lines makes a difference.<br />
Perhaps…perhaps…perhaps…</p>
<p dir="auto">I suppose it would have been best to have the OP’s data file, since it was the one that had the original complaint…</p>
]]></description><link>https://community.notepad-plus-plus.org/post/65276</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/65276</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Fri, 23 Apr 2021 16:38:56 GMT</pubDate></item><item><title><![CDATA[Reply to Poor performance removing blank lines on Fri, 23 Apr 2021 15:32:52 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: Alan-Kilborn">@<bdi>Alan-Kilborn</bdi></a></p>
<p dir="auto">how about</p>
<pre><code class="language-py">editor.setText('A line with some content\n\n'*1000000)
</code></pre>
<p dir="auto">?</p>
]]></description><link>https://community.notepad-plus-plus.org/post/65273</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/65273</guid><dc:creator><![CDATA[Ekopalypse]]></dc:creator><pubDate>Fri, 23 Apr 2021 15:32:52 GMT</pubDate></item><item><title><![CDATA[Reply to Poor performance removing blank lines on Fri, 23 Apr 2021 15:27:32 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/ekopalypse" aria-label="Profile: Ekopalypse">@<bdi>Ekopalypse</bdi></a> said in <a href="/post/65268">Poor performance removing blank lines</a>:</p>
<blockquote>
<p dir="auto">This is quite fast</p>
</blockquote>
<p dir="auto">It almost seems like we need a sample file and then some benchmarking, for all the solutions proposed. :-)</p>
<p dir="auto">Eko’s one-liner removes empty lines AND lines containing only whitespace.  Since N++ makes a distinction (by having two separate menu commands) for those, maybe a one-liner for removing only empty lines is in order?</p>
<p dir="auto">I don’t know if it is totally correct, but I came up with this one:</p>
<pre><code>editor.setText('\r\n'.join(x for x in editor.getText().splitlines() if x != ''))
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/65272</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/65272</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Fri, 23 Apr 2021 15:27:32 GMT</pubDate></item><item><title><![CDATA[Reply to Poor performance removing blank lines on Fri, 23 Apr 2021 14:52:02 GMT]]></title><description><![CDATA[<p dir="auto">This is quite fast</p>
<pre><code class="language-py">editor.setText(''.join(x for x in editor.getText().splitlines(True) if x.strip() != ''))
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/65268</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/65268</guid><dc:creator><![CDATA[Ekopalypse]]></dc:creator><pubDate>Fri, 23 Apr 2021 14:52:02 GMT</pubDate></item><item><title><![CDATA[Reply to Poor performance removing blank lines on Wed, 21 Apr 2021 19:54:22 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: Alan-Kilborn">@<bdi>Alan-Kilborn</bdi></a> said in <a href="/post/65227">Poor performance removing blank lines</a>:</p>
<blockquote>
<p dir="auto">(Note that I don’t care one iota about the obsolete TextFX)</p>
</blockquote>
<p dir="auto">The reason I cared enough to install it on a 32-bit NPP was that, if I had confirmed that TextFX too 1/180th of the time as the builtin, I was going to suggest to the developers that they look into the algorithm that TextFX used and see if they could borrow from it.  But since it was slower in my experiments, there isn’t anything “magical” about their algorithm.</p>
<p dir="auto">I also tried</p>
<pre><code>def delTrulyEmpty(contents, lineNumber, totalLines):
    if contents.strip('\r\n') == "":
        editor.deleteLine(lineNumber)

editor.beginUndoAction()
editor.forEachLine(delTrulyEmpty)
editor.endUndoAction()
</code></pre>
<p dir="auto">… but that was the slowest so far.</p>
<blockquote>
<p dir="auto"><code>^$(\\r\\n|\\r|\\n)</code> which seems like it would be more “effort” than <code>^\R</code></p>
</blockquote>
<p dir="auto">It probably depends on how <code>\R</code> is defined under the Boost regex engine’s hood.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/65228</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/65228</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Wed, 21 Apr 2021 19:54:22 GMT</pubDate></item><item><title><![CDATA[Reply to Poor performance removing blank lines on Wed, 21 Apr 2021 19:44:29 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/peterjones" aria-label="Profile: PeterJones">@<bdi>PeterJones</bdi></a> said in <a href="/post/65226">Poor performance removing blank lines</a>:</p>
<blockquote>
<p dir="auto">it’s because ::removeEmptyLine() code invokes the regex engine, rather than looking at the lines manually.</p>
</blockquote>
<p dir="auto">You raise an interesting point here.<br />
Which choice (of those two) would be faster/slower, on a fixed data set?</p>
<p dir="auto">It is also interesting that Notepad++ uses the regex <code>^$(\\r\\n|\\r|\\n)</code> which seems like it would be more “effort” than <code>^\R</code>, but that could be misleading as well.</p>
<p dir="auto">(Note that I don’t care one iota about the obsolete TextFX)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/65227</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/65227</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Wed, 21 Apr 2021 19:44:29 GMT</pubDate></item><item><title><![CDATA[Reply to Poor performance removing blank lines on Wed, 21 Apr 2021 19:35:29 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/endolith" aria-label="Profile: endolith">@<bdi>endolith</bdi></a> ,</p>
<p dir="auto">For me, a 1M line file, about 30% blank and 70% with 300-character lines, in Notepad++ v7.9.5-32bit, the builtin action took no more than 30sec, whereas the TextFX took considerably longer (multiple minutes).</p>
<p dir="auto">The exact durations may depend on the density of text and maybe other factors.</p>
<p dir="auto">My guess is that if there’s a difference in time for you, and if Notepad++ really is slower, that it’s because <a href="https://github.com/notepad-plus-plus/notepad-plus-plus/blob/9c66ff9c71e12a4c18c7b02e8c221002af27560d/PowerEditor/src/Notepad_plus.cpp#L1399-L1430" rel="nofollow ugc">::removeEmptyLine()</a> code invokes the regex engine, rather than looking at the lines manually.</p>
<p dir="auto">But again, my experiment showed that the TextFX took considerably longer.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/65226</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/65226</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Wed, 21 Apr 2021 19:35:29 GMT</pubDate></item><item><title><![CDATA[Reply to Poor performance removing blank lines on Wed, 21 Apr 2021 19:34:15 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/endolith" aria-label="Profile: endolith">@<bdi>endolith</bdi></a></p>
<p dir="auto">3 minutes does seem excessive.<br />
Maybe still beats the time it would take to do it by hand, though. :-)</p>
<p dir="auto">What’s your timing for a regex replacement operation with that data?</p>
<p dir="auto">find: <code>^\R</code><br />
repl: nothing<br />
search mode: Regular expression</p>
]]></description><link>https://community.notepad-plus-plus.org/post/65225</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/65225</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Wed, 21 Apr 2021 19:34:15 GMT</pubDate></item></channel></rss>