diff options
author | srijan-sivakumar <[email protected]> | 2020-09-26 19:17:41 +0530 |
---|---|---|
committer | MOHIT AGRAWAL <[email protected]> | 2020-09-28 06:09:36 +0000 |
commit | 2d2ea54a2cd895aef40e39109ea98c94aa02a473 (patch) | |
tree | bf8cee1b7c0605ba86fe7a0498ea7c863bffafc1 | |
parent | d34daa73fe6eacaca3b4b3ed666ed44ef5d727b4 (diff) | |
download | glusterfs-2d2ea54a2cd895aef40e39109ea98c94aa02a473.tar.gz glusterfs-2d2ea54a2cd895aef40e39109ea98c94aa02a473.tar.xz glusterfs-2d2ea54a2cd895aef40e39109ea98c94aa02a473.zip |
glusterd: Replacing str with ptr in strchr to reduce comparison
Issue: On seeing the function glusterd_replace_slash_with_hyphen
we see that the strchr inside the while loop takes str as a
parameter, that'd mean repeated comparison from index 0 of str
even though the characters have already been compared. Why not
use ptr instead which points to the latest replacement in the
string.
Code change: replacing str with ptr inside the strchr function.
Fixes: #1516
Change-Id: Id049ec2ad9800a01730f2a0263d9e0528557ae81
Signed-off-by: srijan-sivakumar <[email protected]>
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-store.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c index de932826c9..d94dceb10b 100644 --- a/xlators/mgmt/glusterd/src/glusterd-store.c +++ b/xlators/mgmt/glusterd/src/glusterd-store.c @@ -74,7 +74,7 @@ glusterd_replace_slash_with_hyphen(char *str) while (ptr) { *ptr = '-'; - ptr = strchr(str, '/'); + ptr = strchr(ptr, '/'); } } |