From e51854dd5d4bbc1bc2b6d0643e38e68513256058 Mon Sep 17 00:00:00 2001 From: Paolo Borelli Date: Sun, 18 Mar 2007 23:20:35 +0000 Subject: [PATCH] remove unneeded checks. 2007-03-19 Paolo Borelli * glib/gutf8.c (fast_validate_len): remove unneeded checks. svn path=/trunk/; revision=5427 --- ChangeLog | 4 ++++ glib/gutf8.c | 11 ++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5c87e05..648e1df 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2007-03-19 Paolo Borelli + + * glib/gutf8.c (fast_validate_len): remove unneeded checks. + 2007-03-18 Matthias Clasen * glib/gregex.c: Cosmetic fixes diff --git a/glib/gutf8.c b/glib/gutf8.c index 87dad3f..150980d 100644 --- a/glib/gutf8.c +++ b/glib/gutf8.c @@ -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 -- 2.7.4