From a422af1a7b98a8c05ca61a11025ab71210fcba9a Mon Sep 17 00:00:00 2001 From: "pavel.pimenov" Date: Wed, 12 Jul 2017 19:19:46 +0300 Subject: [PATCH] remove call _strchr _TEXT SEGMENT _c$ = 8 ; size = 1 ?is_space@@YA_ND@Z PROC ; is_space, COMDAT ; 8 : static const char* ws = " \t\n\r\f\v"; ; 9 : return strchr(ws, c) != nullptr; movsx eax, BYTE PTR _c$[esp-4] push eax push DWORD PTR ?ws@?1??is_space@@YA_ND@Z@4PBDB call _strchr add esp, 8 neg eax sbb eax, eax neg eax ; 10 : } --- src/string_util.cpp | 3 +-- test/test_string.cpp | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/string_util.cpp b/src/string_util.cpp index 23804253c..ce7e2bba2 100644 --- a/src/string_util.cpp +++ b/src/string_util.cpp @@ -81,8 +81,7 @@ namespace libtorrent { bool is_space(char c) { - static const char* ws = " \t\n\r\f\v"; - return strchr(ws, c) != nullptr; + return c == ' ' || c == '\t' || c == '\n' || c == '\r' || c == '\f' || c == '\v'; } char to_lower(char c) diff --git a/test/test_string.cpp b/test/test_string.cpp index 95caddf52..ae8f10704 100644 --- a/test/test_string.cpp +++ b/test/test_string.cpp @@ -91,6 +91,8 @@ TORRENT_TEST(is_space) TEST_CHECK(is_space('\t')); TEST_CHECK(is_space('\n')); TEST_CHECK(is_space('\r')); + TEST_CHECK(is_space('\f')); + TEST_CHECK(is_space('\v')); } TORRENT_TEST(to_lower)