diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-02-24 21:28:10 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-02-25 15:03:28 +0000 |
commit | 283e843be91ef4d727c0815d1b8a0420fd16a7fd (patch) | |
tree | 6a24e68688b95e73c5c22bbef272b4f72929096d /hwpfilter | |
parent | 9bc5d4cdf010091406091875e6c45d975ebc9708 (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')
-rw-r--r-- | hwpfilter/qa/cppunit/data/fail/cslist-1.hwp | bin | 0 -> 70566 bytes | |||
-rw-r--r-- | hwpfilter/source/hwpfile.cxx | 83 | ||||
-rw-r--r-- | hwpfilter/source/hwpfile.h | 15 |
3 files changed, 30 insertions, 68 deletions
diff --git a/hwpfilter/qa/cppunit/data/fail/cslist-1.hwp b/hwpfilter/qa/cppunit/data/fail/cslist-1.hwp Binary files differnew file mode 100644 index 000000000000..d491f7b4c04d --- /dev/null +++ b/hwpfilter/qa/cppunit/data/fail/cslist-1.hwp 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) diff --git a/hwpfilter/source/hwpfile.h b/hwpfilter/source/hwpfile.h index 793354e4c508..1d8da3673169 100644 --- a/hwpfilter/source/hwpfile.h +++ b/hwpfilter/source/hwpfile.h @@ -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; |