Junio C Hamano gits...@pobox.com writes:
Michael Haggerty mhag...@alum.mit.edu writes:
I really wish we could mix declarations with statements because I think
it is a big help to readability.
...
Unfortunately, I think we are in violent disagreement.
After re-reading the above, I realize
The beginning of the loop ensures that slash can never be NULL. So
don't keep checking whether it is NULL later in the loop.
Furthermore, there is no need for an early
return it;
from the loop if slash points at the end of the string, because that
is exactly what will happen when the while
Michael Haggerty mhag...@alum.mit.edu writes:
The beginning of the loop ensures that slash can never be NULL. So
don't keep checking whether it is NULL later in the loop.
Furthermore, there is no need for an early
return it;
from the loop if slash points at the end of the string,
On 03/04/2014 10:40 AM, David Kastrup wrote:
Michael Haggerty mhag...@alum.mit.edu writes:
The beginning of the loop ensures that slash can never be NULL. So
don't keep checking whether it is NULL later in the loop.
Furthermore, there is no need for an early
return it;
from the
Michael Haggerty mhag...@alum.mit.edu writes:
BTW, I purposely didn't use a for loop at the end (even though I
usually like them) because I wanted to keep it prominent that path is
being updated to the value of slash. Putting that assignment in a for
loop makes it easy to overlook because it
Michael Haggerty mhag...@alum.mit.edu writes:
while (*path) {
- const char *slash;
struct cache_tree_sub *sub;
+ const char *slash = strchr(path, '/');
- slash = strchr(path, '/');
if (!slash)
On 03/04/2014 10:05 PM, Junio C Hamano wrote:
Michael Haggerty mhag...@alum.mit.edu writes:
while (*path) {
-const char *slash;
struct cache_tree_sub *sub;
+const char *slash = strchr(path, '/');
-slash = strchr(path, '/');
Michael Haggerty mhag...@alum.mit.edu writes:
Isn't the above a strchrnul()?
Oh, cool, I never realized that this GNU extension was blessed for use
in Git. Will change.
We do have our own fallbacks for non-glibc platforms, so it should
be safe.
Combining a freestanding decl with
Junio C Hamano gits...@pobox.com writes:
Michael Haggerty mhag...@alum.mit.edu writes:
while (*path) {
-const char *slash;
struct cache_tree_sub *sub;
+const char *slash = strchr(path, '/');
-slash = strchr(path, '/');
9 matches
Mail list logo