ofz: epic slow use of std::list

Change-Id: I790a3098272101fd33f83f21bdcef1bb061efd76
Reviewed-on: https://gerrit.libreoffice.org/34635
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
This commit is contained in:
Caolán McNamara
2017-02-24 21:28:10 +00:00
parent 9bc5d4cdf0
commit 283e843be9
3 changed files with 30 additions and 68 deletions

Binary file not shown.

View File

@@ -70,7 +70,7 @@ HWPFile::~HWPFile()
for (; it != plist.end(); ++it)
delete *it;
std::list < Table* >::iterator tbl = tables.begin();
std::vector< Table* >::iterator tbl = tables.begin();
for (; tbl != tables.end(); ++tbl)
delete *tbl;
@@ -457,92 +457,53 @@ void HWPFile::AddBox(FBox * box)
blist.push_back(box);
}
ParaShape *HWPFile::getParaShape(int index)
{
std::list<ParaShape*>::iterator it = pslist.begin();
for( int i = 0; it != pslist.end(); ++it, i++ ){
if( i == index )
break;
}
return it != pslist.end() ? *it : nullptr;
if (index < 0 || static_cast<unsigned int>(index) >= pslist.size())
return nullptr;
return pslist[index];
}
CharShape *HWPFile::getCharShape(int index)
{
std::list<CharShape*>::iterator it = cslist.begin();
for( int i = 0; it != cslist.end(); ++it, i++ ){
if( i == index )
break;
}
return it != cslist.end() ? *it : nullptr;
if (index < 0 || static_cast<unsigned int>(index) >= cslist.size())
return nullptr;
return cslist[index];
}
FBoxStyle *HWPFile::getFBoxStyle(int index)
{
std::list<FBoxStyle*>::iterator it = fbslist.begin();
for( int i = 0; it != fbslist.end(); ++it, i++ ){
if( i == index )
break;
}
return it != fbslist.end() ? *it : nullptr;
if (index < 0 || static_cast<unsigned int>(index) >= fbslist.size())
return nullptr;
return fbslist[index];
}
DateCode *HWPFile::getDateCode(int index)
{
std::list<DateCode*>::iterator it = datecodes.begin();
for( int i = 0; it != datecodes.end(); ++it, i++ ){
if( i == index )
break;
}
return it != datecodes.end() ? *it : nullptr;
if (index < 0 || static_cast<unsigned int>(index) >= datecodes.size())
return nullptr;
return datecodes[index];
}
HeaderFooter *HWPFile::getHeaderFooter(int index)
{
std::list<HeaderFooter*>::iterator it = headerfooters.begin();
for( int i = 0; it != headerfooters.end(); ++it, i++ ){
if( i == index )
break;
}
return it != headerfooters.end() ? *it : nullptr;
if (index < 0 || static_cast<unsigned int>(index) >= headerfooters.size())
return nullptr;
return headerfooters[index];
}
ShowPageNum *HWPFile::getPageNumber(int index)
{
std::list<ShowPageNum*>::iterator it = pagenumbers.begin();
for( int i = 0; it != pagenumbers.end(); ++it, i++ ){
if( i == index )
break;
}
return it != pagenumbers.end() ? *it : nullptr;
if (index < 0 || static_cast<unsigned int>(index) >= pagenumbers.size())
return nullptr;
return pagenumbers[index];
}
Table *HWPFile::getTable(int index)
{
std::list<Table*>::iterator it = tables.begin();
for( int i = 0; it != tables.end(); ++it, i++ ){
if( i == index )
break;
}
return it != tables.end() ? *it : nullptr;
if (index < 0 || static_cast<unsigned int>(index) >= tables.size())
return nullptr;
return tables[index];
}
void HWPFile::AddParaShape(ParaShape * pshape)

View File

@@ -26,6 +26,7 @@
#define INCLUDED_HWPFILTER_SOURCE_HWPFILE_H
#include <list>
#include <vector>
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
@@ -282,13 +283,13 @@ class DLLEXPORT HWPFile
std::list<EmPicture*> emblist;
std::list<HyperText*> hyperlist;
int currenthyper;
std::list<ParaShape*> pslist; /* 스타오피스의 구조상 필요 */
std::list<CharShape*> cslist;
std::list<FBoxStyle*> fbslist;
std::list<DateCode*> datecodes;
std::list<HeaderFooter*> headerfooters;
std::list<ShowPageNum*> pagenumbers;
std::list<Table*> tables;
std::vector<ParaShape*> pslist; /* 스타오피스의 구조상 필요 */
std::vector<CharShape*> cslist;
std::vector<FBoxStyle*> fbslist;
std::vector<DateCode*> datecodes;
std::vector<HeaderFooter*> headerfooters;
std::vector<ShowPageNum*> pagenumbers;
std::vector<Table*> tables;
// for global document handling
static HWPFile *cur_doc;