remove unneeded checks.
authorPaolo Borelli <pborelli@katamail.com>
Sun, 18 Mar 2007 23:20:35 +0000 (23:20 +0000)
committerPaolo Borelli <pborelli@src.gnome.org>
Sun, 18 Mar 2007 23:20:35 +0000 (23:20 +0000)
2007-03-19  Paolo Borelli  <pborelli@katamail.com>

* glib/gutf8.c (fast_validate_len): remove unneeded checks.

svn path=/trunk/; revision=5427

ChangeLog
glib/gutf8.c

index 5c87e05..648e1df 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2007-03-19  Paolo Borelli  <pborelli@katamail.com>
+
+       * glib/gutf8.c (fast_validate_len): remove unneeded checks.
+
 2007-03-18  Matthias Clasen  <mclasen@redhat.com>
 
        * glib/gregex.c: Cosmetic fixes
index 87dad3f..150980d 100644 (file)
@@ -1631,7 +1631,9 @@ fast_validate_len (const char *str,
   gunichar min = 0;
   const gchar *p;
 
-  for (p = str; (max_len < 0 || (p - str) < max_len) && *p; p++)
+  g_assert (max_len >= 0);
+
+  for (p = str; ((p - str) < max_len) && *p; p++)
     {
       if (*(guchar *)p < 128)
        /* done */;
@@ -1642,7 +1644,7 @@ fast_validate_len (const char *str,
          last = p;
          if ((*(guchar *)p & 0xe0) == 0xc0) /* 110xxxxx */
            {
-             if (G_UNLIKELY (max_len >= 0 && max_len - (p - str) < 2))
+             if (G_UNLIKELY (max_len - (p - str) < 2))
                goto error;
              
              if (G_UNLIKELY ((*(guchar *)p & 0x1e) == 0))
@@ -1655,7 +1657,7 @@ fast_validate_len (const char *str,
            {
              if ((*(guchar *)p & 0xf0) == 0xe0) /* 1110xxxx */
                {
-                 if (G_UNLIKELY (max_len >= 0 && max_len - (p - str) < 3))
+                 if (G_UNLIKELY (max_len - (p - str) < 3))
                    goto error;
                  
                  min = (1 << 11);
@@ -1664,7 +1666,7 @@ fast_validate_len (const char *str,
                }
              else if ((*(guchar *)p & 0xf8) == 0xf0) /* 11110xxx */
                {
-                 if (G_UNLIKELY (max_len >= 0 && max_len - (p - str) < 4))
+                 if (G_UNLIKELY (max_len - (p - str) < 4))
                    goto error;
                  
                  min = (1 << 16);
@@ -1744,7 +1746,6 @@ g_utf8_validate (const char   *str,
     return TRUE;
 }
 
-
 /**
  * g_unichar_validate:
  * @ch: a Unicode character