From 01f50bba06fde47a304d778522c7f4897b3267e8 Mon Sep 17 00:00:00 2001 From: "[CST] Focus" Date: Tue, 29 May 2012 16:32:07 +0400 Subject: [PATCH] eitd/SIevents.cpp: change SIcomponents and SIparentalRatings from set to vector - no need to sort them, this decrease SIevent size --- src/eitd/SIevents.cpp | 14 +++++++++----- src/eitd/SIevents.hpp | 6 ++++-- src/eitd/xmlutil.cpp | 7 ++++++- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/eitd/SIevents.cpp b/src/eitd/SIevents.cpp index 6f1ebd3cc..3e89ed875 100644 --- a/src/eitd/SIevents.cpp +++ b/src/eitd/SIevents.cpp @@ -176,14 +176,16 @@ void SIevent::parse(Event &event) std::transform(lang.begin(), lang.end(), lang.begin(), tolower); int table = getCountryCodeDefaultMapping(lang); c.component = stringDVBUTF8(d->getText(), table, tsidonid); - components.insert(c); + //components.insert(c); + components.push_back(c); } else if(dtype == PARENTAL_RATING_DESCRIPTOR) { const ParentalRatingDescriptor *d = (ParentalRatingDescriptor*) *dit; const ParentalRatingList *plist = d->getParentalRatings(); for (ParentalRatingConstIterator it = plist->begin(); it != plist->end(); ++it) { SIparentalRating p((*it)->getCountryCode(), (*it)->getRating()); - ratings.insert(p); + //ratings.insert(p); + ratings.push_back(p); } } else if(dtype == LINKAGE_DESCRIPTOR) { @@ -312,7 +314,8 @@ void SIevent::parseContentDescriptor(const uint8_t *buf, unsigned maxlen) void SIevent::parseComponentDescriptor(const uint8_t *buf, unsigned maxlen) { if(maxlen>=sizeof(struct descr_component_header)) - components.insert(SIcomponent((const struct descr_component_header *)buf)); + components.push_back(SIcomponent((const struct descr_component_header *)buf)); + //components.insert(SIcomponent((const struct descr_component_header *)buf)); } void SIevent::parseParentalRatingDescriptor(const uint8_t *buf, unsigned maxlen) @@ -322,7 +325,8 @@ void SIevent::parseParentalRatingDescriptor(const uint8_t *buf, unsigned maxlen) return; const uint8_t *s=buf+sizeof(struct descr_generic_header); while(sdescriptor_length-4) { - ratings.insert(SIparentalRating(std::string((const char *)s, 3), *(s+3))); + //ratings.insert(SIparentalRating(std::string((const char *)s, 3), *(s+3))); + ratings.push_back(SIparentalRating(std::string((const char *)s, 3), *(s+3))); s+=4; } } @@ -336,7 +340,7 @@ void SIevent::parseLinkageDescriptor(const uint8_t *buf, unsigned maxlen) char SIevent::getFSK() const { - for (SIparentalRatings::iterator it = ratings.begin(); it != ratings.end(); ++it) + for (SIparentalRatings::const_iterator it = ratings.begin(); it != ratings.end(); ++it) { if (it->countryCode == "DEU") { diff --git a/src/eitd/SIevents.hpp b/src/eitd/SIevents.hpp index ab26bda55..6caf2447b 100644 --- a/src/eitd/SIevents.hpp +++ b/src/eitd/SIevents.hpp @@ -224,7 +224,8 @@ class SIcomponent } }; -typedef std::multiset > SIcomponents; +//typedef std::multiset > SIcomponents; +typedef std::vector SIcomponents; // Fuer for_each struct printSIcomponent : public std::unary_function @@ -272,7 +273,8 @@ class SIparentalRating (countryCode != p.countryCode); } }; -typedef std::set > SIparentalRatings; +//typedef std::set > SIparentalRatings; +typedef std::vector SIparentalRatings; // Fuer for_each struct printSIparentalRating : public std::unary_function diff --git a/src/eitd/xmlutil.cpp b/src/eitd/xmlutil.cpp index 9754b2b91..5d6963a51 100644 --- a/src/eitd/xmlutil.cpp +++ b/src/eitd/xmlutil.cpp @@ -369,12 +369,17 @@ void *insertEventsfromFile(void * data) c.componentType = xmlGetNumericAttribute(node, "type", 16); c.componentTag = xmlGetNumericAttribute(node, "tag", 16); c.component = std::string(xmlGetAttribute(node, "text")); - e.components.insert(c); + //e.components.insert(c); + e.components.push_back(c); node = node->xmlNextNode; } while (xmlGetNextOccurence(node, "parental_rating") != NULL) { +#if 0 e.ratings.insert(SIparentalRating(std::string(ZapitTools::UTF8_to_Latin1(xmlGetAttribute(node, "country"))), (unsigned char) xmlGetNumericAttribute(node, "rating", 10))); +#endif + e.ratings.push_back(SIparentalRating(std::string(ZapitTools::UTF8_to_Latin1(xmlGetAttribute(node, "country"))), + (unsigned char) xmlGetNumericAttribute(node, "rating", 10))); node = node->xmlNextNode; } while (xmlGetNextOccurence(node, "linkage") != NULL) {