mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 13:10:19 +00:00
58fa613236
This tries to speed up XML loading for large XML files (and thus subsurface startup times) by trimming the fat off our own matching code. The actual libxml overhead (particularly string allocation) tends to be the dominant part, so this only speeds up a big load by about 12% for me, but hey, it can be noticeable. Dirk's example nasty 175MB xml file with ~5200 dives takes "only' 7.7 seconds to load, when it used to take 8.8s. And that's on a fast machine. For smaller xml files, the dynamic loading costs etc startup costs tend to be big enough that the xml parsing costs aren't as noticeable. Aside from switching the node names around to "little endian" (ie least significant name first) format to avoid some unnecessary strlen() calls, this makes the nodename generation use a non-locale 'tolower()', and only decodes up to two levels of names (since that's the maximum we ever match against anyway). It also introduces a "-q" argument to make startup timing easier. Passing in "-q" just makes subsurface quit imediately after doing all necessary startup code. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
57 lines
1.1 KiB
C++
57 lines
1.1 KiB
C++
/* main.c */
|
|
#include <locale.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <stdlib.h>
|
|
#include <time.h>
|
|
|
|
#include "qt-gui.h"
|
|
#include "subsurfacestartup.h"
|
|
#include "qt-ui/mainwindow.h"
|
|
#include "qt-ui/diveplanner.h"
|
|
|
|
#include <QStringList>
|
|
|
|
QTranslator *qtTranslator, *ssrfTranslator;
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
int i;
|
|
bool no_filenames = true;
|
|
|
|
setup_system_prefs();
|
|
prefs = default_prefs;
|
|
|
|
init_ui(&argc, &argv);
|
|
parse_xml_init();
|
|
taglist_init_global();
|
|
|
|
QStringList files;
|
|
QStringList importedFiles;
|
|
QStringList arguments = QCoreApplication::arguments();
|
|
for (i = 1; i < arguments.length(); i++) {
|
|
QString a = arguments.at(i);
|
|
if (a.at(0) == '-') {
|
|
parse_argument(a.toLocal8Bit().data());
|
|
continue;
|
|
}
|
|
if (imported) {
|
|
importedFiles.push_back(a);
|
|
} else {
|
|
no_filenames = false;
|
|
files.push_back(a);
|
|
}
|
|
}
|
|
if (no_filenames) {
|
|
QString defaultFile(prefs.default_filename);
|
|
if (!defaultFile.isEmpty())
|
|
files.push_back( QString(prefs.default_filename) );
|
|
}
|
|
parse_xml_exit();
|
|
mainWindow()->loadFiles(files);
|
|
mainWindow()->importFiles(importedFiles);
|
|
if (!quit)
|
|
run_ui();
|
|
exit_ui();
|
|
return 0;
|
|
}
|