libnvpair.c: replace strstr() with strchr() for a single character

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
This commit is contained in:
rilysh 2024-01-29 23:16:13 +05:30 committed by GitHub
parent c3fd7a5217
commit 0cbf135293
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -383,7 +383,7 @@ nvlist_prtctl_setfmt(nvlist_prtctl_t pctl, enum nvlist_prtctl_fmt which,
pctl->nvprt_btwnarrfmt_nl = 0; pctl->nvprt_btwnarrfmt_nl = 0;
} else { } else {
pctl->nvprt_btwnarrfmt = fmt; pctl->nvprt_btwnarrfmt = fmt;
pctl->nvprt_btwnarrfmt_nl = (strstr(fmt, "\n") != NULL); pctl->nvprt_btwnarrfmt_nl = (strchr(fmt, '\n') != NULL);
} }
break; break;