simplify code
This commit is contained in:
parent
efdee26310
commit
18634602ef
6 changed files with 13 additions and 8 deletions
|
@ -74,10 +74,7 @@ void template_type::strip_whitespace() {
|
|||
|
||||
if ((*it).eol()) {
|
||||
if (has_tag && !non_space) {
|
||||
for (auto cur = line_begin; !(*cur).eol(); ++cur)
|
||||
if ((*cur).token_type() == token::type::partial &&
|
||||
cur != line_begin && (*(cur - 1)).ws_only())
|
||||
(*cur).partial_prefix((*(cur - 1)).raw());
|
||||
store_prefixes(line_begin);
|
||||
|
||||
for (auto cur = line_begin; it != cur - 1;
|
||||
cur = (*cur).ws_only() ? tokens.erase(cur) : cur + 1)
|
||||
|
@ -89,3 +86,10 @@ void template_type::strip_whitespace() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
void template_type::store_prefixes(std::vector<token>::iterator beg) {
|
||||
for (auto cur = beg; !(*cur).eol(); ++cur)
|
||||
if ((*cur).token_type() == token::type::partial &&
|
||||
cur != beg && (*(cur - 1)).ws_only())
|
||||
(*cur).partial_prefix((*(cur - 1)).raw());
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ class template_type {
|
|||
void strip_whitespace();
|
||||
void process_text(citer beg, citer end);
|
||||
void tokenize(const std::string& tmp);
|
||||
void store_prefixes(std::vector<token>::iterator beg);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ class has_token: public boost::static_visitor<bool> {
|
|||
}
|
||||
|
||||
template<class T>
|
||||
inline bool operator()(const T& t) const {
|
||||
bool operator()(const T& t) const {
|
||||
return token == ".";
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace mstch {
|
|||
class is_node_empty: public boost::static_visitor<bool> {
|
||||
public:
|
||||
template<class T>
|
||||
inline bool operator()(const T& t) const {
|
||||
bool operator()(const T& t) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ class render_node: public boost::static_visitor<std::string> {
|
|||
}
|
||||
|
||||
template<class T>
|
||||
inline std::string operator()(const T& t) const {
|
||||
std::string operator()(const T& t) const {
|
||||
return "";
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ class render_section: public boost::static_visitor<std::string> {
|
|||
}
|
||||
|
||||
template<class T>
|
||||
inline std::string operator()(const T& t) const {
|
||||
std::string operator()(const T& t) const {
|
||||
return render_context::push(ctx, t).render(section);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue