summaryrefslogtreecommitdiff
path: root/hwpfilter/source/hwpfile.cxx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2017-02-24 21:28:10 +0000
committerCaolán McNamara <caolanm@redhat.com>2017-02-25 15:03:28 +0000
commit283e843be91ef4d727c0815d1b8a0420fd16a7fd (patch)
tree6a24e68688b95e73c5c22bbef272b4f72929096d /hwpfilter/source/hwpfile.cxx
parent9bc5d4cdf010091406091875e6c45d975ebc9708 (diff)
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>
Diffstat (limited to 'hwpfilter/source/hwpfile.cxx')
-rw-r--r--hwpfilter/source/hwpfile.cxx83
1 files changed, 22 insertions, 61 deletions
diff --git a/hwpfilter/source/hwpfile.cxx b/hwpfilter/source/hwpfile.cxx
index 3abfcac3086b..060312a1a0ea 100644
--- a/hwpfilter/source/hwpfile.cxx
+++ b/hwpfilter/source/hwpfile.cxx
@@ -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)