Thursday, September 11, 2014

Re: sorted file takes much longer to load

On 11 September 2014, Ben Fritz <fritzophrenic@gmail.com> wrote:
> On Thursday, September 11, 2014 7:42:06 AM UTC-5, John Little wrote:
> > On Thursday, September 11, 2014 11:57:56 PM UTC+12, LCD 47 wrote:
> > > I think encoding might also account for the difference.
> >
> > I think you are on to something there. If I sanitize the sorted
> > file with
> > :%s/[^ -~]//g
> > there 14 substitutions on 13 lines, and then save and exit, that
> > file no longer has the slowdown, and the message [converted] does
> > not appear on loading. The fact remains that the original and
> > reversed files still have the same non-printable characters and have
> > no problem.
> >
> I have an idea:
>
> Vim tries every encoding in 'fileencodings', one at a time, until it
> finds one that converts without errors.
>
> If the unsorted file has "bad" characters early in the file, then the
> early encodings in 'fileencodings' will fail quickly.
>
> But if the sorted file places those bad characters late in the file,
> then the conversion may need to read most of the file before it fails,
> repeated for possibly multiple encodings.
>
> This could also explain why your reversed file loads more quickly,
> since bad characters that sort later in the forward sorted file will
> be early in the reverse sort.
[...]

This is more or less what I had in mind too, the extra time is
probably spent re-encoding the file.

To the initial poster: to rule out all interferences, does anything
change if you run something like this:

$ time vim -u NONE -i NONE -N -X file.txt -c q

instead of just

$ time vim -u NONE file.txt -c q

/lcd

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment