MCPcopy Create free account
hub / github.com/AngusJohnson/Clipper2 / SetNeedle

Method SetNeedle

CPP/Utils/ClipFileSave.cpp:144–167  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

142 }
143
144 void SetNeedle(const std::string& needle)
145 {
146 ClearNeedle();
147 needle_len_ = static_cast<int>(needle.size());
148 if (!needle_len_) return;
149
150 //case sensitive needle
151 needle_len_less1 = needle_len_ - 1;
152 needle_.clear();
153 needle_.reserve(needle_len_);
154 for (const char& c : needle) needle_.push_back(static_cast<uint8_t>(c));
155
156 //case insensitive needle
157 needle_ic_ = needle_;
158 for (std::vector< uint8_t>::iterator ui = needle_ic_.begin(); ui != needle_ic_.end(); ++ui)
159 *ui = case_table[*ui];
160
161 std::fill(std::begin(shift), std::begin(shift) + 256, needle_len_);
162 for (uint8_t j = 0; j < needle_len_less1; ++j)
163 shift[needle_[j]] = needle_len_less1 - j;
164
165 jump_ = shift[needle_[needle_len_less1]];
166 shift[needle_[needle_len_less1]] = 0;
167 }
168
169 inline void ClearNeedle()
170 {

Callers

nothing calls this directly

Calls 2

beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected