Dubious diff using --diff-algorithm=histogram

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I've met some strange diff with the histogram algorithm.  I know this
has a lot of magic in it, and it's probably not so trivial to improve,
and maybe my code base is so weird that it makes the histogram do crazy
stuff, but I wanted to show it to you in case there's anything that can
be improved.

So, patience is showing a better diff than histogram, which shouldn't
happen usually, and less in this case, where p++ is such a common thing
to do (although maybe this nxt_slow_path() macro is called a lot in the
file and confuses the histogram?).

Code base: <https://github.com/nginx/unit.git>

Cheers,
Alex

---

alx@asus5775:~/src/nginx/unit/space$ git diff --diff-algorithm=histogram 
diff --git a/src/nxt_http_parse.c b/src/nxt_http_parse.c
index 8646a6ce..92bdfb1f 100644
--- a/src/nxt_http_parse.c
+++ b/src/nxt_http_parse.c
@@ -340,10 +340,10 @@ nxt_http_parse_request_line(nxt_http_request_parse_t *rp, u_char **pos,
 
 space_after_target:
 
-    if (nxt_slow_path(end - p < 10)) {
-
         p++;
 
+    if (nxt_slow_path(end - p < 10)) {
+
         if (p == end) {
             return NXT_AGAIN;
         }
alx@asus5775:~/src/nginx/unit/space$ git diff --diff-algorithm=patience 
diff --git a/src/nxt_http_parse.c b/src/nxt_http_parse.c
index 8646a6ce..92bdfb1f 100644
--- a/src/nxt_http_parse.c
+++ b/src/nxt_http_parse.c
@@ -340,10 +340,10 @@ nxt_http_parse_request_line(nxt_http_request_parse_t *rp, u_char **pos,
 
 space_after_target:
 
+        p++;
+
     if (nxt_slow_path(end - p < 10)) {
 
-        p++;
-
         if (p == end) {
             return NXT_AGAIN;
         }
alx@asus5775:~/src/nginx/unit/space$ git diff --diff-algorithm=myers 
diff --git a/src/nxt_http_parse.c b/src/nxt_http_parse.c
index 8646a6ce..92bdfb1f 100644
--- a/src/nxt_http_parse.c
+++ b/src/nxt_http_parse.c
@@ -340,10 +340,10 @@ nxt_http_parse_request_line(nxt_http_request_parse_t *rp, u_char **pos,
 
 space_after_target:
 
-    if (nxt_slow_path(end - p < 10)) {
-
         p++;
 
+    if (nxt_slow_path(end - p < 10)) {
+
         if (p == end) {
             return NXT_AGAIN;
         }
alx@asus5775:~/src/nginx/unit/space$ git diff --diff-algorithm=minimal 
diff --git a/src/nxt_http_parse.c b/src/nxt_http_parse.c
index 8646a6ce..92bdfb1f 100644
--- a/src/nxt_http_parse.c
+++ b/src/nxt_http_parse.c
@@ -340,10 +340,10 @@ nxt_http_parse_request_line(nxt_http_request_parse_t *rp, u_char **pos,
 
 space_after_target:
 
-    if (nxt_slow_path(end - p < 10)) {
-
         p++;
 
+    if (nxt_slow_path(end - p < 10)) {
+
         if (p == end) {
             return NXT_AGAIN;
         }



-- 
<http://www.alejandro-colomar.es/>
GPG key fingerprint: A9348594CE31283A826FBDD8D57633D441E25BB5

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux