Greatly improved I/O speed on gorgonsub

Originally committed to SVN as r2053.
This commit is contained in:
Rodrigo Braz Monteiro 2008-03-14 06:10:54 +00:00
parent 521632cd9b
commit 108671175c
3 changed files with 18 additions and 7 deletions

View file

@ -59,8 +59,9 @@ ActionListPtr Controller::CreateActionList(const String title,const String owner
void Controller::LoadFile(const String filename,const String encoding)
{
const FormatPtr handler = FormatManager::GetFormatFromFilename(filename,true);
wxFileInputStream stream(filename);
model.Load(stream,handler,encoding);
wxFFileInputStream stream(filename);
wxBufferedInputStream buffer(stream);
model.Load(buffer,handler,encoding);
}
@ -69,8 +70,9 @@ void Controller::LoadFile(const String filename,const String encoding)
void Controller::SaveFile(const String filename,const String encoding)
{
const FormatPtr handler = FormatManager::GetFormatFromFilename(filename,true);
wxFileOutputStream stream(filename);
model.Save(stream,handler,encoding);
wxFFileOutputStream stream(filename);
wxBufferedOutputStream buffer(stream);
model.Save(buffer,handler,encoding);
}

View file

@ -36,6 +36,7 @@
#include <aegilib/gorgonsub.h>
#include <wx/wfstream.h>
#include <iostream>
#include <wx/stopwatch.h>
#include "text_file_reader.h"
#include "text_file_writer.h"
@ -53,11 +54,14 @@ int main () {
// Subtitles model
Model subs;
Controller control(subs);
wxStopWatch timer;
// Load subtitles
cout << "Loading file... ";
timer.Start();
control.LoadFile(L"subs_in.ass",L"UTF-8");
cout << "Done.\n";
timer.Pause();
cout << "Done in " << timer.Time() << "ms.\n";
// Create line to be inserted
cout << "Creating data... ";
@ -67,11 +71,13 @@ int main () {
// Create action list
cout << "Processing actions... ";
timer.Start();
ActionListPtr actions = control.CreateActionList(L"Insert line");
actions->InsertLine(line,2);
actions->RemoveLine(3,L"Events");
actions->Finish();
cout << "Done.\n";
timer.Pause();
cout << "Done in " << timer.Time() << "ms.\n";
// Save subtitles
cout << "Saving file... ";
@ -95,8 +101,10 @@ int main () {
// Save subtitles
cout << "Saving file... ";
timer.Start();
control.SaveFile(L"subs_out.ass",L"UTF-8");
cout << "Done.\n";
timer.Pause();
cout << "Done in " << timer.Time() << "ms.\n";
}
catch (std::exception &e) {

View file

@ -143,6 +143,7 @@
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
Profile="true"
/>
<Tool
Name="VCALinkTool"