summaryrefslogtreecommitdiff
path: root/l10ntools/source/merge.cxx
diff options
context:
space:
mode:
authorZolnai Tamás <zolnaitamas2000@gmail.com>2013-05-02 12:09:35 +0200
committerZolnai Tamás <zolnaitamas2000@gmail.com>2013-05-02 12:15:22 +0200
commitc7ef2522272579a12eecddded0cbed6d222d3742 (patch)
treecaf2cdf898ce2e84eb66a5f328c08192454681c7 /l10ntools/source/merge.cxx
parent3ec2d26dc2017ac4a27483febfc63328632f352d (diff)
Make localization a bit more effective
1. get rid of some unefficiency The "old" executables used to parse items which has other language than en-US. To this items executables search MergeEntrys(read from po) and change the content if possible. This mixed localization method not need any longer. -cfgex: cfgmerge:WorkOnText() -xrmex: xrmmerge:WorkOnText() -transex3: export:PrepareTextToMerge() 2. Change the container of MergeData to get a bit efficiency. The new MergeDataHashMap is exploit that in most case the insertion and search happen in the same order.(similar to fifo) So add an iterator-chain to define an insertion order in the original hashmap. Every call of find it is a hint that the next element, to the last found one, is the searched one. If not than search such like in a HasMap. 3. Set up some order in helpex Helpex is the only one, which was not used to merge strings in the same order as export, so change it to work effective with the new HashMap. Helpex works with all file of a specific directory and po files contain the strings of these files in lexical order so use the same order for merge.(HelpTarget.mk) 4. Make export use MergeDataHashMap a bit more effective -The same MergeData contains strings to all language, so it need to get only once. -Just text entrys have MergeData, others not need to search for it. (e.g. bitmap) Plus delete some unused code. Change-Id: I6ec80cd2323ffea8f783d0b59dc89ca7eac3c205
Diffstat (limited to 'l10ntools/source/merge.cxx')
-rw-r--r--l10ntools/source/merge.cxx84
1 files changed, 72 insertions, 12 deletions
diff --git a/l10ntools/source/merge.cxx b/l10ntools/source/merge.cxx
index 498962f34d59..ce2864a8a7eb 100644
--- a/l10ntools/source/merge.cxx
+++ b/l10ntools/source/merge.cxx
@@ -188,6 +188,60 @@ OString MergeEntrys::GetQTZText(const ResData& rResData, const OString& rOrigTex
}
//
+// class MergeDataHashMap
+//
+
+std::pair<MergeDataHashMap::iterator,bool> MergeDataHashMap::insert(const OString& rKey, MergeData* pMergeData)
+{
+ std::pair<iterator,bool> aTemp = m_aHashMap.insert(HashMap_t::value_type( rKey, pMergeData ));
+ if( m_aHashMap.size() == 1 )
+ {
+ ///When first insert, set an iterator to the first element
+ aFirstInOrder = aTemp.first;
+ }
+ else
+ {
+ ///Define insertion order by setting an iterator to the next element.
+ aLastInsertion->second->m_aNextData = aTemp.first;
+ }
+ aLastInsertion = aTemp.first;
+ return aTemp;
+}
+
+MergeDataHashMap::iterator MergeDataHashMap::find(const OString& rKey)
+{
+ iterator aHint = m_aHashMap.end();
+
+ ///Add a hint
+ if( bFirstSearch && !m_aHashMap.empty() )
+ {
+ aHint = aFirstInOrder;
+ }
+ else if( aLastFound == aLastInsertion )
+ {
+ /// Next to the last element is the first element
+ aHint = aFirstInOrder;
+ }
+ else if( aLastFound != m_aHashMap.end() && aLastFound != aLastInsertion )
+ {
+ aHint = aLastFound->second->m_aNextData;
+ }
+
+ ///If hint works than no need for search
+ if( aHint != m_aHashMap.end() && aHint->first == rKey )
+ {
+ aLastFound = aHint;
+ }
+ else
+ {
+ aLastFound = m_aHashMap.find(rKey);
+ }
+
+ bFirstSearch = false;
+ return aLastFound;
+}
+
+//
// class MergeData
//
@@ -310,7 +364,8 @@ MergeDataFile::MergeDataFile(
InsertEntry(
aActPo.getResourceType(), aActPo.getGroupId(),
aActPo.getLocalId(), sLang, sText,
- sQHText, sTitle, aActPo.getSourceFile(), bCaseSensitive );
+ sQHText, sTitle, aActPo.getSourceFile(),
+ bFirstLang, bCaseSensitive );
if( bFirstLang && bWithQtz &&
( strcmp(getenv("ENABLE_RELEASE_BUILD"),"TRUE") ) )
@@ -321,7 +376,7 @@ MergeDataFile::MergeDataFile(
aActPo.getLocalId(), "qtz",
sExText, sExQHText,
sExTitle, aActPo.getSourceFile(),
- bCaseSensitive );
+ false, bCaseSensitive );
}
}
aPoInput.close();
@@ -357,11 +412,12 @@ MergeData *MergeDataFile::GetMergeData( ResData *pResData , bool bCaseSensitive
OString sKey = CreateKey( pResData->sResTyp , pResData->sGId , pResData->sId , pResData->sFilename , bCaseSensitive );
- if(aMap.find( sKey ) != aMap.end())
+ MergeDataHashMap::const_iterator mit = aMap.find( sKey );
+ if(mit != aMap.end())
{
pResData->sGId = sOldG;
pResData->sId = sOldL;
- return aMap[ sKey ];
+ return mit->second;
}
pResData->sGId = sOldG;
pResData->sId = sOldL;
@@ -391,24 +447,28 @@ void MergeDataFile::InsertEntry(
const OString &rLID, const OString &nLANG,
const OString &rTEXT, const OString &rQHTEXT,
const OString &rTITLE, const OString &rInFilename,
- bool bCaseSensitive )
+ bool bFirstLang, bool bCaseSensitive )
{
- MergeData *pData;
+ MergeData *pData = 0;
// search for MergeData
OString sKey = CreateKey(rTYP , rGID , rLID , rInFilename , bCaseSensitive);
- MergeDataHashMap::const_iterator mit;
- mit = aMap.find( sKey );
- if( mit != aMap.end() )
+
+ if( !bFirstLang )
{
- pData = mit->second;
+ MergeDataHashMap::const_iterator mit = aMap.find( sKey );
+ if(mit != aMap.end())
+ pData = mit->second;
+
}
- else
+
+ if( !pData )
{
pData = new MergeData( rTYP, rGID, rLID, rInFilename );
- aMap.insert( MergeDataHashMap::value_type( sKey, pData ) );
+ aMap.insert( sKey, pData );
}
+
// insert the cur string
MergeEntrys *pMergeEntrys = pData->GetMergeEntries();
if( nLANG =="qtz" )