lkml.org 
[lkml]   [2019]   [May]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] mm/slub: avoid double string traverse in kmem_cache_flags()
Date
If ',' is not found, kmem_cache_flags() calls strlen() to find the end
of line. We can do it in a single pass using strchrnul().

Signed-off-by: Yury Norov <ynorov@marvell.com>
---
mm/slub.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/mm/slub.c b/mm/slub.c
index 4922a0394757..85f90370a293 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -1317,9 +1317,7 @@ slab_flags_t kmem_cache_flags(unsigned int object_size,
char *end, *glob;
size_t cmplen;

- end = strchr(iter, ',');
- if (!end)
- end = iter + strlen(iter);
+ end = strchrnul(iter, ',');

glob = strnchr(iter, end - iter, '*');
if (glob)
--
2.17.1
\
 
 \ /
  Last update: 2019-05-01 07:31    [W:0.044 / U:0.008 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site