summaryrefslogtreecommitdiff
path: root/src/basic/string-util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2017-07-20 14:17:30 +0200
committerSven Eden <yamakuzure@gmx.net>2017-07-20 14:17:30 +0200
commitdd5771a663622a14e16971f2afb119fb91c6fade (patch)
treeb2363d03db22a726479354791754052f9a08fd0f /src/basic/string-util.c
parent07d8f20b72e7e18c0e06aa152264c1abbdd09609 (diff)
string-util: optimize strshorten() a bit
There's no reason to determine the full length of the string, it's sufficient to know whether it is larger than the intended size...
Diffstat (limited to 'src/basic/string-util.c')
-rw-r--r--src/basic/string-util.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/basic/string-util.c b/src/basic/string-util.c
index 4bfce5a5d..5172ac775 100644
--- a/src/basic/string-util.c
+++ b/src/basic/string-util.c
@@ -562,7 +562,7 @@ bool nulstr_contains(const char *nulstr, const char *needle) {
char* strshorten(char *s, size_t l) {
assert(s);
- if (l < strlen(s))
+ if (strnlen(s, l+1) > l)
s[l] = 0;
return s;