[cg3] 01/03: Imported Upstream version 0.9.9~r10793

Tino Didriksen tinodidriksen-guest at moszumanska.debian.org
Tue Jun 23 09:41:18 UTC 2015


This is an automated email from the git hooks/post-receive script.

tinodidriksen-guest pushed a commit to branch master
in repository cg3.

commit 26bae8dad2b1a1588b3992c4d118ad316046b31c
Author: Tino Didriksen <mail at tinodidriksen.com>
Date:   Tue Jun 23 09:40:32 2015 +0000

    Imported Upstream version 0.9.9~r10793
---
 ChangeLog                          | 13 ++++++++-----
 scripts/profile-revisions.php      |  2 +-
 src/Cohort.cpp                     |  5 -----
 src/Cohort.hpp                     |  2 +-
 src/Grammar.cpp                    |  5 ++++-
 src/Grammar.hpp                    |  4 ++--
 src/GrammarApplicator_matchSet.cpp | 10 ++++++----
 src/GrammarApplicator_reflow.cpp   |  3 ++-
 src/GrammarApplicator_runRules.cpp |  7 +++++--
 src/inlines.hpp                    |  6 +++---
 src/stdafx.hpp                     |  1 +
 src/version.hpp                    |  2 +-
 12 files changed, 34 insertions(+), 26 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 7870961..91d12a7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2015-06-23  tino
+
+	* [r10791] ChangeLog, src/Grammar.hpp, src/Reading.cpp,
+	  src/flat_unordered_map.hpp, src/flat_unordered_set.hpp,
+	  src/sorted_vector.hpp, src/version.hpp: Let's ship a complete
+	  implementation of flat hash table, instead of the half-baked
+	  monster
+
 2015-06-21  tino
 
 	* [r10787] scripts/profile-revisions.php,
@@ -2320,8 +2328,3 @@
 	  src/GrammarApplicator_runRules.cpp, src/version.h: Context tests
 	  looking at Deleted and Delayed need to bypass the cache.
 
-2012-10-18  tino
-
-	* [r8630] src/GrammarApplicator_runGrammar.cpp, src/inlines.h: CG-3
-	  recognize \v as newline and fix buffer growth
-
diff --git a/scripts/profile-revisions.php b/scripts/profile-revisions.php
index bbcf1a1..089b400 100755
--- a/scripts/profile-revisions.php
+++ b/scripts/profile-revisions.php
@@ -74,7 +74,7 @@ function profile_revision($rev) {
 }
 
 $revs = array(10373, 10297, 10034, 10016, 9645, 9274, 9249, 8923, 8001, 7397, 7134, 7000, 6987, 6898, 6885, 6781, 6692, 6500, 6328, 6268, 6242, 6170, 5932, 5930, 5926, 5918, 5839, 5810, 5773, 5729, 5431, 5129, 5042, 4879, 4779, 4545, 4513, 4493, 4474, 4410, 4292, 4031, 3991, 3896, 3852, 3800, 3689, 3682, 3617);
-$revs = array(10786);
+$revs = array(10791);
 foreach ($revs as $rev) {
 	profile_revision($rev);
 }
diff --git a/src/Cohort.cpp b/src/Cohort.cpp
index a7667c6..eac90ff 100644
--- a/src/Cohort.cpp
+++ b/src/Cohort.cpp
@@ -30,8 +30,6 @@
 
 namespace CG3 {
 
-static std::vector<uint32FlatHashSet> pool_ps;
-
 Cohort::Cohort(SingleWindow *p) :
 type(0),
 global_number(0),
@@ -48,8 +46,6 @@ next(0)
 	#ifdef CG_TRACE_OBJECTS
 	std::cerr << "OBJECT: " << __PRETTY_FUNCTION__ << std::endl;
 	#endif
-
-	pool_get(pool_ps, possible_sets);
 }
 
 Cohort::~Cohort() {
@@ -74,7 +70,6 @@ Cohort::~Cohort() {
 		parent->parent->dep_window.erase(global_number);
 	}
 	detach();
-	pool_put(pool_ps, possible_sets);
 }
 
 void Cohort::detach() {
diff --git a/src/Cohort.hpp b/src/Cohort.hpp
index 3f3fb04..f6f4219 100644
--- a/src/Cohort.hpp
+++ b/src/Cohort.hpp
@@ -62,7 +62,7 @@ namespace CG3 {
 		typedef bc::flat_map<uint32_t,int32_t> num_t;
 		num_t num_max, num_min;
 		uint32SortedVector dep_children;
-		uint32FlatHashSet possible_sets;
+		boost::dynamic_bitset<> possible_sets;
 		CohortVector enclosed;
 		CohortVector removed;
 		RelationCtn relations;
diff --git a/src/Grammar.cpp b/src/Grammar.cpp
index d3d01ee..8de11b4 100644
--- a/src/Grammar.cpp
+++ b/src/Grammar.cpp
@@ -945,7 +945,10 @@ void Grammar::indexSets(uint32_t r, Set *s) {
 }
 
 void Grammar::indexTagToSet(uint32_t t, uint32_t r) {
-	sets_by_tag[t].insert(r);
+	if (sets_by_tag.find(t) == sets_by_tag.end()) {
+		sets_by_tag[t].resize(sets_list.size());
+	}
+	sets_by_tag[t].set(r);
 }
 
 void Grammar::setAdjustSets(Set *s) {
diff --git a/src/Grammar.hpp b/src/Grammar.hpp
index 380bd0c..8c0961a 100644
--- a/src/Grammar.hpp
+++ b/src/Grammar.hpp
@@ -77,11 +77,11 @@ namespace CG3 {
 		rules_by_set_t rules_by_set;
 		typedef stdext::hash_map<uint32_t, uint32IntervalVector> rules_by_tag_t;
 		rules_by_tag_t rules_by_tag;
-		typedef stdext::hash_map<uint32_t, uint32SortedVector> sets_by_tag_t;
+		typedef stdext::hash_map<uint32_t, boost::dynamic_bitset<> > sets_by_tag_t;
 		sets_by_tag_t sets_by_tag;
 
 		uint32IntervalVector *rules_any;
-		uint32SortedVector *sets_any;
+		boost::dynamic_bitset<> *sets_any;
 
 		Set *delimiters;
 		Set *soft_delimiters;
diff --git a/src/GrammarApplicator_matchSet.cpp b/src/GrammarApplicator_matchSet.cpp
index 431b8be..4be9904 100644
--- a/src/GrammarApplicator_matchSet.cpp
+++ b/src/GrammarApplicator_matchSet.cpp
@@ -748,7 +748,7 @@ inline bool GrammarApplicator::doesSetMatchCohort_helper(Cohort& cohort, const R
 bool GrammarApplicator::doesSetMatchCohortNormal(Cohort& cohort, const uint32_t set, dSMC_Context *context) {
 	bool retval = false;
 
-	if (!(!context || (context->options & (POS_LOOK_DELETED | POS_LOOK_DELAYED | POS_NOT))) && cohort.possible_sets.find(set) == cohort.possible_sets.end()) {
+	if (!(!context || (context->options & (POS_LOOK_DELETED | POS_LOOK_DELAYED | POS_NOT))) && (set >= cohort.possible_sets.size() || !cohort.possible_sets.test(set))) {
 		return retval;
 	}
 
@@ -797,8 +797,10 @@ bool GrammarApplicator::doesSetMatchCohortNormal(Cohort& cohort, const uint32_t
 	}
 
 	if (context && !context->matched_target) {
-		if (!grammar->sets_any || grammar->sets_any->find(set) == grammar->sets_any->end()) {
-			cohort.possible_sets.erase(set);
+		if (!grammar->sets_any || set >= grammar->sets_any->size() || !grammar->sets_any->test(set)) {
+			if (set < cohort.possible_sets.size()) {
+				cohort.possible_sets.reset(set);
+			}
 		}
 	}
 
@@ -808,7 +810,7 @@ bool GrammarApplicator::doesSetMatchCohortNormal(Cohort& cohort, const uint32_t
 bool GrammarApplicator::doesSetMatchCohortCareful(Cohort& cohort, const uint32_t set, dSMC_Context *context) {
 	bool retval = false;
 
-	if (!(!context || (context->options & (POS_LOOK_DELETED | POS_LOOK_DELAYED | POS_NOT))) && cohort.possible_sets.find(set) == cohort.possible_sets.end()) {
+	if (!(!context || (context->options & (POS_LOOK_DELETED | POS_LOOK_DELAYED | POS_NOT))) && (set >= cohort.possible_sets.size() || !cohort.possible_sets.test(set))) {
 		return retval;
 	}
 
diff --git a/src/GrammarApplicator_reflow.cpp b/src/GrammarApplicator_reflow.cpp
index 15c3c24..7e98013 100644
--- a/src/GrammarApplicator_reflow.cpp
+++ b/src/GrammarApplicator_reflow.cpp
@@ -458,7 +458,8 @@ uint32_t GrammarApplicator::addTagToReading(Reading& reading, Tag *tag, bool reh
 
 	Grammar::sets_by_tag_t::const_iterator it = grammar->sets_by_tag.find(tag->hash);
 	if (it != grammar->sets_by_tag.end()) {
-		reading.parent->possible_sets.insert(it->second.begin(), it->second.end());
+		reading.parent->possible_sets.resize(std::max(reading.parent->possible_sets.size(), it->second.size()));
+		reading.parent->possible_sets |= it->second;
 	}
 	reading.tags.insert(tag->hash);
 	reading.tags_list.push_back(tag->hash);
diff --git a/src/GrammarApplicator_runRules.cpp b/src/GrammarApplicator_runRules.cpp
index 2413374..94ddcbe 100644
--- a/src/GrammarApplicator_runRules.cpp
+++ b/src/GrammarApplicator_runRules.cpp
@@ -92,7 +92,10 @@ void GrammarApplicator::indexSingleWindow(SingleWindow& current) {
 
 	foreach (CohortVector, current.cohorts, iter, iter_end) {
 		Cohort *c = *iter;
-		boost_foreach (uint32_t psit, c->possible_sets) {
+		for (uint32_t psit = 0; psit < c->possible_sets.size(); ++psit) {
+			if (c->possible_sets.test(psit) == false) {
+				continue;
+			}
 			BOOST_AUTO(rules_it, grammar->rules_by_set.find(psit));
 			if (rules_it == grammar->rules_by_set.end()) {
 				continue;
@@ -330,7 +333,7 @@ uint32_t GrammarApplicator::runRulesOnSingleWindow(SingleWindow& current, const
 				continue;
 			}
 			// If there is not even a remote chance the target set might match this cohort, skip it.
-			if (rule.sub_reading == 0 && cohort->possible_sets.find(rule.target) == cohort->possible_sets.end()) {
+			if (rule.sub_reading == 0 && (rule.target >= cohort->possible_sets.size() || !cohort->possible_sets.test(rule.target))) {
 				continue;
 			}
 
diff --git a/src/inlines.hpp b/src/inlines.hpp
index 41e0223..5e09bee 100644
--- a/src/inlines.hpp
+++ b/src/inlines.hpp
@@ -332,10 +332,10 @@ inline bool index_matches(const Cont& index, const VT& entry) {
 	return (index.find(entry) != index.end());
 }
 
-template<typename IT, typename OT>
-inline void insert_if_exists(IT& cont, const OT* other) {
+inline void insert_if_exists(boost::dynamic_bitset<>& cont, const boost::dynamic_bitset<>* other) {
 	if (other && !other->empty()) {
-		cont.insert(other->begin(), other->end());
+		cont.resize(std::max(cont.size(), other->size()));
+		cont |= *other;
 	}
 }
 
diff --git a/src/stdafx.hpp b/src/stdafx.hpp
index 018a2bf..5f300a5 100644
--- a/src/stdafx.hpp
+++ b/src/stdafx.hpp
@@ -81,6 +81,7 @@
 #include <boost/unordered_map.hpp>
 #include <boost/container/flat_set.hpp>
 #include <boost/container/flat_map.hpp>
+#include <boost/dynamic_bitset.hpp>
 #include <boost/scoped_ptr.hpp>
 #include <boost/typeof/typeof.hpp>
 #include <boost/foreach.hpp>
diff --git a/src/version.hpp b/src/version.hpp
index 656c494..05bb28e 100644
--- a/src/version.hpp
+++ b/src/version.hpp
@@ -30,7 +30,7 @@ const char* const CG3_COPYRIGHT_STRING = "Copyright (C) 2007-2015 GrammarSoft Ap
 const uint32_t CG3_VERSION_MAJOR = 0;
 const uint32_t CG3_VERSION_MINOR = 9;
 const uint32_t CG3_VERSION_PATCH = 9;
-const uint32_t CG3_REVISION = 10791;
+const uint32_t CG3_REVISION = 10793;
 const uint32_t CG3_FEATURE_REV = 10575;
 const uint32_t CG3_TOO_OLD = 10373;
 const uint32_t CG3_EXTERNAL_PROTOCOL = 7226;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/cg3.git



More information about the debian-science-commits mailing list