aboutsummaryrefslogtreecommitdiff
path: root/libxsde/xsde/cxx/hybrid/parser-map.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2010-10-18 11:17:51 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2010-10-18 11:17:51 +0200
commitd80d096ee8743fd6f7382d274272b0b6d7faf9bf (patch)
treed0f0bee1e645cb2b86b6837ac0db8a7d2821e533 /libxsde/xsde/cxx/hybrid/parser-map.cxx
parent0e4637025fa8d1b4234b0512561d31f0dd023843 (diff)
Support for schema evolution using substitution groups
New examples: hybrid/evolution/ignore and hybrid/evolution/passthrough.
Diffstat (limited to 'libxsde/xsde/cxx/hybrid/parser-map.cxx')
-rw-r--r--libxsde/xsde/cxx/hybrid/parser-map.cxx17
1 files changed, 10 insertions, 7 deletions
diff --git a/libxsde/xsde/cxx/hybrid/parser-map.cxx b/libxsde/xsde/cxx/hybrid/parser-map.cxx
index ae67b94..33b0a53 100644
--- a/libxsde/xsde/cxx/hybrid/parser-map.cxx
+++ b/libxsde/xsde/cxx/hybrid/parser-map.cxx
@@ -21,23 +21,26 @@ namespace xsde
if (size_ == 0)
return 0;
+ int r (1);
+ size_t m;
size_t l = 0;
size_t h = size_ - 1;
while (l <= h)
{
- size_t m = l + (h - l)/2;
- int r = strcmp (entries_[m].type_id, tid);
+ m = l + (h - l)/2;
+ r = strcmp (entries_[m].type_id, tid);
- if (r > 0)
- h = m - 1;
- else if (r < 0)
+ if (r == 0 || l == h)
+ break;
+
+ if (r < 0)
l = m + 1;
else
- return entries_[m].parser;
+ h = (m == 0 ? 0 : m - 1);
}
- return 0;
+ return r == 0 ? entries_[m].parser : 0;
}
void parser_map_impl::