]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
2009-08-24 Vladimir Serbinenko <phcoder@gmail.com>
authorphcoder <phcoder@localhost>
Mon, 24 Aug 2009 19:40:40 +0000 (19:40 +0000)
committerphcoder <phcoder@localhost>
Mon, 24 Aug 2009 19:40:40 +0000 (19:40 +0000)
Save space by inlining misc.c functions.

* kern/misc.c (grub_iswordseparator): Made static.
* kern/misc.c (grub_strcat): Moved from here ...
* include/grub/misc.h (grub_strcat): ... here. Inlined.
* kern/misc.c (grub_strncat): Moved from here ...
* include/grub/misc.h (grub_strncat): ... here. Inlined.
* kern/misc.c (grub_strcasecmp): Moved from here ...
* include/grub/misc.h (grub_strcasecmp): ... here. Inlined.
* kern/misc.c (grub_strncasecmp): Moved from here ...
* include/grub/misc.h (grub_strncasecmp): ... here. Inlined.
* kern/misc.c (grub_isalpha): Moved from here ...
* include/grub/misc.h (grub_isalpha): ... here. Inlined.
* kern/misc.c (grub_isdigit): Moved from here ...
* include/grub/misc.h (grub_isdigit): ... here. Inlined.
* kern/misc.c (grub_isgraph): Moved from here ...
* include/grub/misc.h (grub_isgraph): ... here. Inlined.
* kern/misc.c (grub_tolower): Moved from here ...
* include/grub/misc.h (grub_tolower): ... here. Inlined.

ChangeLog
include/grub/misc.h
kern/misc.c

index a8c30d971dbeaa636907889704c5a3c79df91809..f9c915016187247c8fa4db159a9338d27287c988 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2009-08-24  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       Save space by inlining misc.c functions.
+
+       * kern/misc.c (grub_iswordseparator): Made static.
+       * kern/misc.c (grub_strcat): Moved from here ...
+       * include/grub/misc.h (grub_strcat): ... here. Inlined.
+       * kern/misc.c (grub_strncat): Moved from here ...
+       * include/grub/misc.h (grub_strncat): ... here. Inlined.
+       * kern/misc.c (grub_strcasecmp): Moved from here ...
+       * include/grub/misc.h (grub_strcasecmp): ... here. Inlined.
+       * kern/misc.c (grub_strncasecmp): Moved from here ...
+       * include/grub/misc.h (grub_strncasecmp): ... here. Inlined.
+       * kern/misc.c (grub_isalpha): Moved from here ...
+       * include/grub/misc.h (grub_isalpha): ... here. Inlined.
+       * kern/misc.c (grub_isdigit): Moved from here ...
+       * include/grub/misc.h (grub_isdigit): ... here. Inlined.
+       * kern/misc.c (grub_isgraph): Moved from here ...
+       * include/grub/misc.h (grub_isgraph): ... here. Inlined.
+       * kern/misc.c (grub_tolower): Moved from here ...
+       * include/grub/misc.h (grub_tolower): ... here. Inlined.
+
 2009-08-24  Vladimir Serbinenko  <phcoder@gmail.com>
 
        * script/sh/function.c (grub_script_function_find): Cut error message
index 769ec5cd830c7f2992981f390ca6ea2bde745a69..a63a0b4426fe1c6c7901ee1cd5d2f70415c42001 100644 (file)
@@ -37,8 +37,42 @@ void *EXPORT_FUNC(grub_memmove) (void *dest, const void *src, grub_size_t n);
 char *EXPORT_FUNC(grub_strcpy) (char *dest, const char *src);
 char *EXPORT_FUNC(grub_strncpy) (char *dest, const char *src, int c);
 char *EXPORT_FUNC(grub_stpcpy) (char *dest, const char *src);
-char *EXPORT_FUNC(grub_strcat) (char *dest, const char *src);
-char *EXPORT_FUNC(grub_strncat) (char *dest, const char *src, int c);
+
+static inline char *
+grub_strcat (char *dest, const char *src)
+{
+  char *p = dest;
+
+  while (*p)
+    p++;
+
+  while ((*p = *src) != '\0')
+    {
+      p++;
+      src++;
+    }
+
+  return dest;
+}
+
+static inline char *
+grub_strncat (char *dest, const char *src, int c)
+{
+  char *p = dest;
+
+  while (*p)
+    p++;
+
+  while ((*p = *src) != '\0' && c--)
+    {
+      p++;
+      src++;
+    }
+
+  *p = '\0';
+
+  return dest;
+}
 
 /* Prototypes for aliases.  */
 #if !defined (GRUB_UTIL) || !defined (APPLE_CC)
@@ -49,19 +83,41 @@ void *EXPORT_FUNC(memcpy) (void *dest, const void *src, grub_size_t n);
 int EXPORT_FUNC(grub_memcmp) (const void *s1, const void *s2, grub_size_t n);
 int EXPORT_FUNC(grub_strcmp) (const char *s1, const char *s2);
 int EXPORT_FUNC(grub_strncmp) (const char *s1, const char *s2, grub_size_t n);
-int EXPORT_FUNC(grub_strcasecmp) (const char *s1, const char *s2);
-int EXPORT_FUNC(grub_strncasecmp) (const char *s1, const char *s2, grub_size_t n);
+
 char *EXPORT_FUNC(grub_strchr) (const char *s, int c);
 char *EXPORT_FUNC(grub_strrchr) (const char *s, int c);
 int EXPORT_FUNC(grub_strword) (const char *s, const char *w);
 char *EXPORT_FUNC(grub_strstr) (const char *haystack, const char *needle);
-int EXPORT_FUNC(grub_iswordseparator) (int c);
 int EXPORT_FUNC(grub_isspace) (int c);
 int EXPORT_FUNC(grub_isprint) (int c);
-int EXPORT_FUNC(grub_isalpha) (int c);
-int EXPORT_FUNC(grub_isgraph) (int c);
-int EXPORT_FUNC(grub_isdigit) (int c);
-int EXPORT_FUNC(grub_tolower) (int c);
+
+static inline int
+grub_isalpha (int c)
+{
+  return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
+}
+
+static inline int
+grub_isgraph (int c)
+{
+  return (c >= '!' && c <= '~');
+}
+
+static inline int
+grub_isdigit (int c)
+{
+  return (c >= '0' && c <= '9');
+}
+
+static inline int
+grub_tolower (int c)
+{
+  if (c >= 'A' && c <= 'Z')
+    return c - 'A' + 'a';
+
+  return c;
+}
+
 static inline int
 grub_toupper (int c)
 {
@@ -71,6 +127,40 @@ grub_toupper (int c)
   return c;
 }
 
+static inline int
+grub_strcasecmp (const char *s1, const char *s2)
+{
+  while (*s1 && *s2)
+    {
+      if (grub_tolower (*s1) != grub_tolower (*s2))
+       break;
+
+      s1++;
+      s2++;
+    }
+
+  return (int) grub_tolower (*s1) - (int) grub_tolower (*s2);
+}
+
+static inline int
+grub_strncasecmp (const char *s1, const char *s2, grub_size_t n)
+{
+  if (n == 0)
+    return 0;
+
+  while (*s1 && *s2 && --n)
+    {
+      if (grub_tolower (*s1) != grub_tolower (*s2))
+       break;
+
+      s1++;
+      s2++;
+    }
+
+  return (int) grub_tolower (*s1) - (int) grub_tolower (*s2);
+}
+
+
 unsigned long EXPORT_FUNC(grub_strtoul) (const char *str, char **end, int base);
 unsigned long long EXPORT_FUNC(grub_strtoull) (const char *str, char **end, int base);
 char *EXPORT_FUNC(grub_strdup) (const char *s);
index d797f17814000863f44722224dac167601f2baf5..1c38fe661baed462a85d370bdded6f4cf67e4d84 100644 (file)
 #include <grub/term.h>
 #include <grub/env.h>
 
+static int
+grub_iswordseparator (int c)
+{
+  return (grub_isspace (c) || c == ',' || c == ';' || c == '|' || c == '&');
+}
+
 void *
 grub_memmove (void *dest, const void *src, grub_size_t n)
 {
@@ -97,42 +103,6 @@ grub_stpcpy (char *dest, const char *src)
   return d - 1;
 }
 
-char *
-grub_strcat (char *dest, const char *src)
-{
-  char *p = dest;
-
-  while (*p)
-    p++;
-
-  while ((*p = *src) != '\0')
-    {
-      p++;
-      src++;
-    }
-
-  return dest;
-}
-
-char *
-grub_strncat (char *dest, const char *src, int c)
-{
-  char *p = dest;
-
-  while (*p)
-    p++;
-
-  while ((*p = *src) != '\0' && c--)
-    {
-      p++;
-      src++;
-    }
-
-  *p = '\0';
-
-  return dest;
-}
-
 int
 grub_printf (const char *fmt, ...)
 {
@@ -250,39 +220,6 @@ grub_strncmp (const char *s1, const char *s2, grub_size_t n)
   return (int) *s1 - (int) *s2;
 }
 
-int
-grub_strcasecmp (const char *s1, const char *s2)
-{
-  while (*s1 && *s2)
-    {
-      if (grub_tolower (*s1) != grub_tolower (*s2))
-       break;
-
-      s1++;
-      s2++;
-    }
-
-  return (int) grub_tolower (*s1) - (int) grub_tolower (*s2);
-}
-
-int
-grub_strncasecmp (const char *s1, const char *s2, grub_size_t n)
-{
-  if (n == 0)
-    return 0;
-
-  while (*s1 && *s2 && --n)
-    {
-      if (grub_tolower (*s1) != grub_tolower (*s2))
-       break;
-
-      s1++;
-      s2++;
-    }
-
-  return (int) grub_tolower (*s1) - (int) grub_tolower (*s2);
-}
-
 char *
 grub_strchr (const char *s, int c)
 {
@@ -394,12 +331,6 @@ grub_strword (const char *haystack, const char *needle)
   return 0;
 }
 
-int
-grub_iswordseparator (int c)
-{
-  return (grub_isspace (c) || c == ',' || c == ';' || c == '|' || c == '&');
-}
-
 int
 grub_isspace (int c)
 {
@@ -412,33 +343,6 @@ grub_isprint (int c)
   return (c >= ' ' && c <= '~');
 }
 
-int
-grub_isalpha (int c)
-{
-  return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
-}
-
-int
-grub_isdigit (int c)
-{
-  return (c >= '0' && c <= '9');
-}
-
-int
-grub_isgraph (int c)
-{
-  return (c >= '!' && c <= '~');
-}
-
-int
-grub_tolower (int c)
-{
-  if (c >= 'A' && c <= 'Z')
-    return c - 'A' + 'a';
-
-  return c;
-}
-
 
 unsigned long
 grub_strtoul (const char *str, char **end, int base)