summaryrefslogtreecommitdiff
path: root/sax
diff options
context:
space:
mode:
authorMohammed Abdul Azeem <azeemmysore@gmail.com>2016-07-28 23:10:12 +0530
committerMichael Meeks <michael.meeks@collabora.com>2016-07-29 22:15:11 +0000
commit916a11d26cb74da9dd534e07b35737def6cbf54a (patch)
treecfd12d3167f74249f5723e7476612fafbb49777a /sax
parent7f32fddb445ef1c1e17f9028f252c21dd83e03af (diff)
GSoC - moving FastAttributeList::clear to consumer thread:
this shares the load of clearing the attributes list with the consumer when producer is busy. Change-Id: I6e89858703c7af9c30b2d99fd6825dc81290b488 Reviewed-on: https://gerrit.libreoffice.org/27649 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Diffstat (limited to 'sax')
-rw-r--r--sax/source/fastparser/fastparser.cxx50
1 files changed, 42 insertions, 8 deletions
diff --git a/sax/source/fastparser/fastparser.cxx b/sax/source/fastparser/fastparser.cxx
index ab324a1f40db..8fa922379f64 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -70,7 +70,11 @@ struct Entity;
typedef std::unordered_map< OUString, sal_Int32,
OUStringHash > NamespaceMap;
-typedef std::vector<Event> EventList;
+struct EventList
+{
+ std::vector<Event> maEvents;
+ bool mbIsAttributesEmpty;
+};
enum CallbackType { INVALID, START_ELEMENT, END_ELEMENT, CHARACTERS, DONE, EXCEPTION };
@@ -531,7 +535,7 @@ EventList* Entity::getEventList()
if (!mpProducedEvents)
{
mpProducedEvents = new EventList();
- mpProducedEvents->resize(mnEventListSize);
+ mpProducedEvents->maEvents.resize(mnEventListSize);
mnProducedEventsSize = 0;
}
}
@@ -544,7 +548,7 @@ Event& Entity::getEvent( CallbackType aType )
return maSharedEvent;
EventList* pEventList = getEventList();
- Event& rEvent = (*pEventList)[mnProducedEventsSize++];
+ Event& rEvent = pEventList->maEvents[mnProducedEventsSize++];
rEvent.maType = aType;
return rEvent;
}
@@ -783,6 +787,24 @@ void FastSaxParserImpl::parseStream(const InputSource& maStructSource)
done = true;
aGuard.reset(); // lock
+
+ if ( rEntity.maPendingEvents.size() <= rEntity.mnEventLowWater )
+ {
+ aGuard.clear();
+ for (auto aEventIt = pEventList->maEvents.begin();
+ aEventIt != pEventList->maEvents.end(); ++aEventIt)
+ {
+ if (aEventIt->mxAttributes.is())
+ {
+ aEventIt->mxAttributes->clear();
+ if( rEntity.mxNamespaceHandler.is() )
+ aEventIt->mxDeclAttributes->clear();
+ }
+ pEventList->mbIsAttributesEmpty = true;
+ }
+ aGuard.reset();
+ }
+
rEntity.maUsedEvents.push(pEventList);
}
} while (!done);
@@ -926,8 +948,9 @@ void FastSaxParserImpl::produce( bool bForceFlush )
bool FastSaxParserImpl::consume(EventList *pEventList)
{
Entity& rEntity = getEntity();
- for (EventList::iterator aEventIt = pEventList->begin();
- aEventIt != pEventList->end(); ++aEventIt)
+ pEventList->mbIsAttributesEmpty = false;
+ for (auto aEventIt = pEventList->maEvents.begin();
+ aEventIt != pEventList->maEvents.end(); ++aEventIt)
{
switch ((*aEventIt).maType)
{
@@ -1042,17 +1065,28 @@ void FastSaxParserImpl::callbackStartElement(const xmlChar *localName , const xm
}
// create attribute map and process namespace instructions
- Event& rEvent = getEntity().getEvent( START_ELEMENT );
+ Event& rEvent = rEntity.getEvent( START_ELEMENT );
+ bool bIsAttributesEmpty = false;
+ if ( rEntity.mbEnableThreads )
+ bIsAttributesEmpty = rEntity.getEventList()->mbIsAttributesEmpty;
+
if (rEvent.mxAttributes.is())
- rEvent.mxAttributes->clear();
+ {
+ if( !bIsAttributesEmpty )
+ rEvent.mxAttributes->clear();
+ }
else
rEvent.mxAttributes.set(
new FastAttributeList( rEntity.mxTokenHandler,
rEntity.mpTokenHandler ) );
+
if( rEntity.mxNamespaceHandler.is() )
{
if (rEvent.mxDeclAttributes.is())
- rEvent.mxDeclAttributes->clear();
+ {
+ if( !bIsAttributesEmpty )
+ rEvent.mxDeclAttributes->clear();
+ }
else
rEvent.mxDeclAttributes.set(
new FastAttributeList( rEntity.mxTokenHandler,