MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / Negate

Method Negate

extern/re2/re2/regexp.cc:884–916  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

882}
883
884void CharClassBuilder::Negate() {
885 // Build up negation and then copy in.
886 // Could edit ranges in place, but C++ won't let me.
887 std::vector<RuneRange> v;
888 v.reserve(ranges_.size() + 1);
889
890 // In negation, first range begins at 0, unless
891 // the current class begins at 0.
892 iterator it = begin();
893 if (it == end()) {
894 v.push_back(RuneRange(0, Runemax));
895 } else {
896 int nextlo = 0;
897 if (it->lo == 0) {
898 nextlo = it->hi + 1;
899 ++it;
900 }
901 for (; it != end(); ++it) {
902 v.push_back(RuneRange(nextlo, it->lo - 1));
903 nextlo = it->hi + 1;
904 }
905 if (nextlo <= Runemax)
906 v.push_back(RuneRange(nextlo, Runemax));
907 }
908
909 ranges_.clear();
910 for (size_t i = 0; i < v.size(); i++)
911 ranges_.insert(v[i]);
912
913 upper_ = AlphaMask & ~upper_;
914 lower_ = AlphaMask & ~lower_;
915 nrunes_ = Runemax+1 - nrunes_;
916}
917
918// Character class is a sorted list of ranges.
919// The ranges are allocated in the same block as the header,

Callers 4

PostVisitMethod · 0.80
AddUGroupFunction · 0.80
ParseCharClassMethod · 0.80
NegateFunction · 0.80

Calls 8

RuneRangeClass · 0.85
beginFunction · 0.50
endFunction · 0.50
reserveMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45
clearMethod · 0.45
insertMethod · 0.45

Tested by 1

NegateFunction · 0.64