lkml.org 
[lkml]   [2016]   [Sep]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 19/29] lib/ucs2_string: Speed up ucs2_utf8size()
    Date
    From: Lukas Wunner <lukas@wunner.de>

    No need to calculate the string length on every loop iteration.

    Signed-off-by: Lukas Wunner <lukas@wunner.de>
    Cc: Peter Jones <pjones@redhat.com>
    Signed-off-by: Matt Fleming <matt@codeblueprint.co.uk>
    ---
    lib/ucs2_string.c | 2 +-
    1 file changed, 1 insertion(+), 1 deletion(-)

    diff --git a/lib/ucs2_string.c b/lib/ucs2_string.c
    index f0b323abb4c6..ae8d2491133c 100644
    --- a/lib/ucs2_string.c
    +++ b/lib/ucs2_string.c
    @@ -56,7 +56,7 @@ ucs2_utf8size(const ucs2_char_t *src)
    unsigned long i;
    unsigned long j = 0;

    - for (i = 0; i < ucs2_strlen(src); i++) {
    + for (i = 0; src[i]; i++) {
    u16 c = src[i];

    if (c >= 0x800)
    --
    2.9.3
    \
     
     \ /
      Last update: 2016-09-17 09:59    [W:4.222 / U:0.088 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site