sublime_text
sublime_text copied to clipboard
Find previous is slower than find next
Description
In a file with some rare characters, find previous freezes and takes a long time while find next is instantaneous.
Steps to reproduce
- Run the program at the end to make such a file. (200 MB)
- Open it, and find "a" without regex or case matching. Just case insensitive string search.
- Experiment with enter & shift+enter.
Expected behavior
Equally performant ?
Actual behavior
Shift+enter is slower than enter.
Environment
Build 3211 macOS Mojave.
#include <iostream>
#include <fstream>
#include <ostream>
#include <string>
const int TOTAL{1000 * 1000 * 50};
const std::string STORAGE{"bcdefghijklmnopqrstuvwxyz1234567890"}; // 26 - 1 + 10
const size_t SIZE{STORAGE.size()};
int main(int argc, const char *argv[])
{
std::ofstream outfile_s{"a.txt"};
if (outfile_s.bad()) {
std::cerr << "Couldn't open file." << std::endl;
return -1;
}
outfile_s << "a\n";
for (int i = 0; i < TOTAL; i++) {
outfile_s << STORAGE[rand() % SIZE] << "\n";
}
outfile_s << "a\n";
for (int i = 0; i < TOTAL; i++) {
outfile_s << STORAGE[rand() % SIZE] << "\n";
}
return 0;
}
If I am remembering the implementation correctly, I believe this has do to with how backwards searches are performed. To find the previous match it searches from the beginning of the buffer to the current match and then selects the final match.
I just want to add and confirm about this issue. I tested with the 5million lines CSV data from here: link from EForExcel.com
I tested in Sublime Safe Mode, vanilla BBEdit, minimal configuration (no plugin) terminal vim, and vanilla terminal emacs.
It's not quite a fair comparison, but BBEdit, terminal vim, and terminal emacs (haven't tried GUI Emacs) can perform backward search (and even replace) in less than 3 seconds.
Do we expect any fix for this issue? it seems to be an old one looking at the date