simplify code

This commit is contained in:
Daniel Sipka 2015-05-05 08:49:42 +02:00
parent efdee26310
commit 18634602ef
6 changed files with 13 additions and 8 deletions

View File

@ -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());
}

View File

@ -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);
};
}

View File

@ -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 == ".";
}

View File

@ -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;
}

View File

@ -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 "";
}

View File

@ -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);
}