WERD_RES: Remove comparisons which are constant

This fixes warnings from LGTM:

Comparison is always false because id >= 0.
Comparison is always true because mirrored >= 1.
Comparison is always false because id >= 0.

INVALID_UNICHAR_ID is -1, so the warnings are correct.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
Stefan Weil 2018-10-06 20:06:38 +02:00
parent 238c872753
commit 18f7ab751e

View File

@ -363,10 +363,10 @@ class WERD_RES : public ELIST_LINK {
blob_index >= best_choice->length()) blob_index >= best_choice->length())
return nullptr; return nullptr;
UNICHAR_ID id = best_choice->unichar_id(blob_index); UNICHAR_ID id = best_choice->unichar_id(blob_index);
if (id < 0 || id >= uch_set->size() || id == INVALID_UNICHAR_ID) if (id < 0 || id >= uch_set->size())
return nullptr; return nullptr;
UNICHAR_ID mirrored = uch_set->get_mirror(id); UNICHAR_ID mirrored = uch_set->get_mirror(id);
if (in_rtl_context && mirrored > 0 && mirrored != INVALID_UNICHAR_ID) if (in_rtl_context && mirrored > 0)
id = mirrored; id = mirrored;
return uch_set->id_to_unichar_ext(id); return uch_set->id_to_unichar_ext(id);
} }
@ -375,7 +375,7 @@ class WERD_RES : public ELIST_LINK {
if (blob_index < 0 || blob_index >= raw_choice->length()) if (blob_index < 0 || blob_index >= raw_choice->length())
return nullptr; return nullptr;
UNICHAR_ID id = raw_choice->unichar_id(blob_index); UNICHAR_ID id = raw_choice->unichar_id(blob_index);
if (id < 0 || id >= uch_set->size() || id == INVALID_UNICHAR_ID) if (id < 0 || id >= uch_set->size())
return nullptr; return nullptr;
return uch_set->id_to_unichar(id); return uch_set->id_to_unichar(id);
} }