Skip to content

Commit

Permalink
libnvpair.c: replace strstr() with strchr() for a single character
Browse files Browse the repository at this point in the history
Since we're looking for a single new-line character in the haystack,
it's better (and slightly more efficient) to use strchr() instead of
strstr().

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Signed-off-by: rilysh <nightquick@proton.me>
Closes #15798
  • Loading branch information
rilysh authored Jan 29, 2024
1 parent c3fd7a5 commit 0cbf135
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/libnvpair/libnvpair.c
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ nvlist_prtctl_setfmt(nvlist_prtctl_t pctl, enum nvlist_prtctl_fmt which,
pctl->nvprt_btwnarrfmt_nl = 0;
} else {
pctl->nvprt_btwnarrfmt = fmt;
pctl->nvprt_btwnarrfmt_nl = (strstr(fmt, "\n") != NULL);
pctl->nvprt_btwnarrfmt_nl = (strchr(fmt, '\n') != NULL);
}
break;

Expand Down

0 comments on commit 0cbf135

Please sign in to comment.