pixitha commented on code in PR #13173:
URL: https://github.com/apache/trafficserver/pull/13173#discussion_r3281606265
##########
plugins/esi/lib/EsiParser.cc:
##########
@@ -182,68 +183,52 @@ EsiParser::_compareData(const string &data, size_t pos,
const char *str, int str
return PARTIAL_MATCH;
}
-/** This implementation is optimized but not completely correct. If
- * the opening tag were to have a repeating opening sequence ('<e<esi'
- * or something like that), this will break. However that is not the
- * case for the two opening tags we are looking for */
+/** Uses memchr to skip non-'<' bytes, then memcmp to verify each candidate
+ * anchor. Delegates scanning to the platform's optimized memchr
+ * implementation. Does not have the KMP-failure limitation of the original
+ * state-machine. */
EsiParser::MATCH_TYPE
EsiParser::_findOpeningTag(const string &data, size_t start_pos, size_t
&opening_tag_pos, bool &is_html_comment_node) const
{
- size_t i_data = start_pos;
- int i_esi = 0, i_html_comment = 0;
-
- while (i_data < data.size()) {
- if (data[i_data] == ESI_TAG_PREFIX[i_esi]) {
- if (++i_esi == ESI_TAG_PREFIX_LEN) {
- is_html_comment_node = false;
- opening_tag_pos = i_data - i_esi + 1;
+ const char *const buf = data.data();
Review Comment:
I was mostly unaware of what was offered in libswoc, so that's def why I
didn't use it. I did some quick benchmarks with a synthetic comparison between
this vs TextView and libswoc is as fast if not slightly faster sometimes. Its
within margin of error, so Its more up to you guys if you want it re-written
that way now, or something we should tackle later?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]