Attemp at scaling the spacing between lines to better fill the text box;

Did some profiling, conclusions:
 - we want to buffer our input streams, apperantly wx doesn't do this automatically
 - compiling regexes is SLOW.
   This is not just in the numbers, but it is actually noticable! The textbox used to be quite unresponsive.
   I wrapped the call to filter_text in the game file with a quick contains() call, so usually, the regex doesn't fire.
   It would be nicer if this was somehow automatic, but that will not be easy.

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@627 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2007-08-25 00:02:33 +00:00
parent ca55a4d5da
commit 694566fef4
6 changed files with 102 additions and 31 deletions
+22 -2
View File
@@ -155,6 +155,26 @@ class ZipFileInputStream : private wxFileInputStream, public wxZipInputStream {
};
#endif
class BufferedFileInputStream_aux {
protected:
wxFileInputStream file_stream;
inline BufferedFileInputStream_aux(const String& filename)
: file_stream(filename)
{}
};
/// A buffered version of wxFileInputStream
/** 2007-08-24:
* According to profiling this gives a significant speedup
* Bringing the avarage run time of read_utf8_line from 186k to 54k (in cpu time units)
*/
class BufferedFileInputStream : private BufferedFileInputStream_aux, public wxBufferedInputStream {
public:
inline BufferedFileInputStream(const String& filename)
: BufferedFileInputStream_aux(filename)
, wxBufferedInputStream(file_stream)
{}
};
InputStreamP Package::openIn(const String& file) {
if (!file.empty() && file.GetChar(0) == _('/')) {
// absolute path, open file from another package
@@ -167,10 +187,10 @@ InputStreamP Package::openIn(const String& file) {
InputStreamP stream;
if (it->second.wasWritten()) {
// written to this file, open the temp file
stream = new_shared1<wxFileInputStream>(it->second.tempName);
stream = new_shared1<BufferedFileInputStream>(it->second.tempName);
} else if (wxFileExists(filename+_("/")+file)) {
// a file in directory package
stream = new_shared1<wxFileInputStream>(filename+_("/")+file);
stream = new_shared1<BufferedFileInputStream>(filename+_("/")+file);
} else if (wxFileExists(filename) && it->second.zipEntry) {
// a file in a zip archive
// somebody in wx thought seeking was no longer needed, it now only works with the 'compatability constructor'