mirror of
				https://github.com/vdr-projects/vdr.git
				synced 2025-03-01 10:50:46 +00:00 
			
		
		
		
	Made skipspace() an inline function and changed it to handle the most common case of 'no leading space' very fast, and avoid calling isspace()
This commit is contained in:
		@@ -2114,3 +2114,4 @@ Patrice Staudt <staudt@engsystem.net>
 | 
			
		||||
 | 
			
		||||
Tobias Bratfisch <tobias@reel-multimedia.com>
 | 
			
		||||
 for improving numdigits(), isnumber() and strreplace()
 | 
			
		||||
 for suggesting to make skipspace() an inline function
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										5
									
								
								HISTORY
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								HISTORY
									
									
									
									
									
								
							@@ -5276,7 +5276,7 @@ Video Disk Recorder Revision History
 | 
			
		||||
- Improved performance of the SVDRP commands LSTC and CHAN when used with a
 | 
			
		||||
  channel name.
 | 
			
		||||
 | 
			
		||||
2007-07-20: Version 1.5.6
 | 
			
		||||
2007-07-21: Version 1.5.6
 | 
			
		||||
 | 
			
		||||
- Fixed a buffer overflow in initializing the system character table (thanks
 | 
			
		||||
  to Marco Schl<68><6C>ler).
 | 
			
		||||
@@ -5290,3 +5290,6 @@ Video Disk Recorder Revision History
 | 
			
		||||
- Updated the Finnish OSD texts (thanks to Rolf Ahrenberg).
 | 
			
		||||
- Improved cControl::Launch() to keep 'control' from pointing to uninitialized
 | 
			
		||||
  memory (thanks to Rolf Ahrenberg).
 | 
			
		||||
- Made skipspace() an inline function (suggested by Tobias Bratfisch) and changed
 | 
			
		||||
  it to handle the most common case of 'no leading space' very fast, and avoid
 | 
			
		||||
  calling isspace(), which made the whole function a lot faster.
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										9
									
								
								tools.c
									
									
									
									
									
								
							
							
						
						
									
										9
									
								
								tools.c
									
									
									
									
									
								
							@@ -4,7 +4,7 @@
 | 
			
		||||
 * See the main source file 'vdr.c' for copyright information and
 | 
			
		||||
 * how to reach the author.
 | 
			
		||||
 *
 | 
			
		||||
 * $Id: tools.c 1.133 2007/07/20 14:25:46 kls Exp $
 | 
			
		||||
 * $Id: tools.c 1.134 2007/07/21 13:02:45 kls Exp $
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "tools.h"
 | 
			
		||||
@@ -167,13 +167,6 @@ char *strreplace(char *s, const char *s1, const char *s2)
 | 
			
		||||
  return s;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
char *skipspace(const char *s)
 | 
			
		||||
{
 | 
			
		||||
  while (*s && isspace(*s))
 | 
			
		||||
        s++;
 | 
			
		||||
  return (char *)s;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
char *stripspace(char *s)
 | 
			
		||||
{
 | 
			
		||||
  if (s && *s) {
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										11
									
								
								tools.h
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								tools.h
									
									
									
									
									
								
							@@ -4,7 +4,7 @@
 | 
			
		||||
 * See the main source file 'vdr.c' for copyright information and
 | 
			
		||||
 * how to reach the author.
 | 
			
		||||
 *
 | 
			
		||||
 * $Id: tools.h 1.103 2007/06/23 13:34:28 kls Exp $
 | 
			
		||||
 * $Id: tools.h 1.104 2007/07/21 13:35:45 kls Exp $
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifndef __TOOLS_H
 | 
			
		||||
@@ -173,7 +173,14 @@ char *strcpyrealloc(char *dest, const char *src);
 | 
			
		||||
char *strn0cpy(char *dest, const char *src, size_t n);
 | 
			
		||||
char *strreplace(char *s, char c1, char c2);
 | 
			
		||||
char *strreplace(char *s, const char *s1, const char *s2); ///< re-allocates 's' and deletes the original string if necessary!
 | 
			
		||||
char *skipspace(const char *s);
 | 
			
		||||
inline char *skipspace(const char *s)
 | 
			
		||||
{
 | 
			
		||||
  if (*s > ' ') // most strings don't have any leading space, so handle this case as fast as possible
 | 
			
		||||
     return (char *)s;
 | 
			
		||||
  while (*s && *s <= ' ') // avoiding isspace() here, because it is much slower
 | 
			
		||||
        s++;
 | 
			
		||||
  return (char *)s;
 | 
			
		||||
}
 | 
			
		||||
char *stripspace(char *s);
 | 
			
		||||
char *compactspace(char *s);
 | 
			
		||||
cString strescape(const char *s, const char *chars);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user