From 2d2ea54a2cd895aef40e39109ea98c94aa02a473 Mon Sep 17 00:00:00 2001 From: srijan-sivakumar Date: Sat, 26 Sep 2020 19:17:41 +0530 Subject: 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 --- xlators/mgmt/glusterd/src/glusterd-store.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'xlators/mgmt/glusterd') diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c index de932826c90..d94dceb10b7 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, '/'); } } -- cgit