From 214e2c12b8ed4ab99ecc5ea97b971ee8cf2b9605 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sat, 19 Aug 2000 10:53:56 +0000 Subject: [PATCH] Avoid generating stupid but correct code. --- ChangeLog | 3 +++ src/key-list.cc | 10 ++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index d400932..69dba0e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2000-08-19 Bruno Haible + * src/key-list.cc (Key_List::output_lookup_function_body): Avoid + outputting a trivially satisfied test for len. + * src/key-list.cc (output_keyword_entry): Avoid outputting a struct initializer of the form {"key",}. diff --git a/src/key-list.cc b/src/key-list.cc index 21b27a1..b7931c1 100644 --- a/src/key-list.cc +++ b/src/key-list.cc @@ -1523,8 +1523,14 @@ Key_List::output_lookup_function_body (const Output_Compare& comparison) { T (Trace t ("Key_List::output_lookup_function_body");) - printf (" if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)\n" - " {\n" + /* Since `len' is of type `unsigned int', we can avoid comparing it + against zero. */ + if (min_key_len == 0) + printf (" if (len <= MAX_WORD_LENGTH)\n"); + else + printf (" if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)\n"); + + printf (" {\n" " register int key = %s (str, len);\n\n", option.get_hash_name ());