Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Register
  • Sign in
  • L linux
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • Deployments
    • Deployments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • Kirill Smelkov
  • linux
  • Repository
  • linux
  • lib
  • string.c
Find file BlameHistoryPermalink
  • André Goddard Rosa's avatar
    string: factorize skip_spaces and export it to be generally available · f653398c
    André Goddard Rosa authored Dec 14, 2009
    
    
    On the following sentence:
        while (*s && isspace(*s))
            s++;
    
    If *s == 0, isspace() evaluates to ((_ctype[*s] & 0x20) != 0), which
    evaluates to ((0x08 & 0x20) != 0) which equals to 0 as well.
    If *s == 1, we depend on isspace() result anyway. In other words,
    "a char equals zero is never a space", so remove this check.
    
    Also, *s != 0 is most common case (non-null string).
    
    Fixed const return as noticed by Jan Engelhardt and James Bottomley.
    Fixed unnecessary extra cast on strstrip() as noticed by Jan Engelhardt.
    
    Signed-off-by: default avatarAndré Goddard Rosa <andre.goddard@gmail.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    f653398c
GitLab Nexedi Edition | About GitLab | About Nexedi | 沪ICP备2021021310号-2 | 沪ICP备2021021310号-7