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

Re: [PATCH v5 01/14] Add data structures and basic functions for commit trailers

From: Eric Sunshine <hidden>
Date: 2016-06-15 22:59:52

On Sun, Feb 9, 2014 at 8:48 AM, Christian Couder
[off-list ref] wrote:
From: Junio C Hamano <redacted>
quoted
Christian Couder [off-list ref] writes:
quoted
+static inline int same_trailer(struct trailer_item *a, struct trailer_item *b, int alnum_len)
+{
+    return same_token(a, b, alnum_len) && same_value(a, b);
+}
All these "inlines" look premature optimization that can be
delegated to any decent compiler, don't they?
Yeah, but as Eric suggested to add them like in header files and you
did not reply to him, I thought you agreed with him.
I will remove them.
If these functions are used only by trailer.c, then it would make
sense to move them from trailer.h to trailer.c so that they don't get
defined unnecessarily by each .c file which includes trailer.h.
quoted
quoted
+/* Get the length of buf from its beginning until its last alphanumeric character */
+static inline size_t alnum_len(const char *buf, int len)
+{
+    while (--len >= 0 && !isalnum(buf[len]));
+    return (size_t) len + 1;
This is somewhat unfortunate.  if the caller wants to receive
size_t, perhaps it should be passing in size_t (or ssize_t) to the
function?  Hard to guess without an actual caller, though.
Ok, I will make it return an int.
Why not adjust the loop condition slightly instead so that you can
continue to accept and return size_t?
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help