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
  • tools
  • perf
  • util
  • string.c
Find file BlameHistoryPermalink
  • Arnaldo Carvalho de Melo's avatar
    perf string: Simplify ltrim() implementation · ecbe5e10
    Arnaldo Carvalho de Melo authored Apr 07, 2017
    We don't need to use strlen(), a var, or check for the end explicitely,
    isspace('\0') is false:
    
      [acme@jouet c]$ cat ltrim.c
      #include <ctype.h>
      #include <stdio.h>
    
      static char *ltrim(char *s)
      {
    	  while (isspace(*s))
    		  ++s;
    	  return s;
      }
    
      int main(void)
      {
    	  printf("ltrim(\"\")='%s'\n", ltrim(""));
    	  return 0;
      }
      [acme@jouet c]$ ./ltrim
      ltrim("")=''
      [acme@jouet c]$
    
    Cc: Jiri Olsa <jolsa@kernel.org>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Taeung Song <treeze.taeung@gmail.com>
    Link: http://lkml.kernel.org/n/tip-w3nk0x3pai2vojk2ab6kdvaw@git.kernel.org
    
    
    Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    ecbe5e10
GitLab Nexedi Edition | About GitLab | About Nexedi | 沪ICP备2021021310号-2 | 沪ICP备2021021310号-7