Thread (16 messages) flat view 16 messages, 3 authors, 2016-06-15

Re: [PATCH 1/7] commit: provide a function to find a header in a buffer

From: Jeff King <hidden>
Date: 2016-06-15 23:01:43

On Sun, Jun 22, 2014 at 09:26:44PM -0400, Eric Sunshine wrote:
quoted
+               if (line == eol)
+                       return NULL;
+               next = *eol ? eol + 1 : NULL;
+
+               if (eol - line > key_len &&
+                   !strncmp(line, key, key_len) &&
+                   line[key_len] == ' ') {
+                       *out_len = eol - line - key_len - 1;
+                       return line + key_len + 1;
+               }
+               line = next;
This is already simplified from the original implementation in
get_header(), but it can be simplified further by dropping 'next',
which is not otherwise used, and assigning 'line' directly:

    line = *eol ? eol + 1 : NULL;
Yeah, you're right. Squashed, thanks.

-Peff
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help