Optimize explore_check_company_suffix

This commit is contained in:
twinaphex 2020-09-27 23:55:50 +02:00
parent 3c2280b2b2
commit 2e5bfd74ec

View File

@ -343,18 +343,24 @@ static int explore_qsort_func_menulist(const void *a_, const void *b_)
static int explore_check_company_suffix(const char* p, bool search_reverse) static int explore_check_company_suffix(const char* p, bool search_reverse)
{ {
int p0, p0_lc, p1, p1_lc, p2, p2_lc;
if (search_reverse) if (search_reverse)
{ {
p -= (p[-1] == '.' ? 4 : 3); p -= (p[-1] == '.' ? 4 : 3);
if (p[-1] != ' ') if (p[-1] != ' ')
return 0; return 0;
} }
if (tolower(p[0]) == 'i' && tolower(p[1]) == 'n' && tolower(p[2]) == 'c') p0 = p[0];
return (p[3] == '.' ? 4 : 3); /*, Inc */ p1 = p[1];
if (tolower(p[0]) == 'l' && tolower(p[1] )== 't' && tolower(p[2]) == 'd') p2 = p[2];
return (p[3] == '.' ? 4 : 3); /*, Ltd */ p0_lc = TOLOWER(p0);
if (tolower(p[0]) == 't' && tolower(p[1] )== 'h' && tolower(p[2]) == 'e') p1_lc = TOLOWER(p1);
return (p[3] == '.' ? 4 : 3); /*, The */ p2_lc = TOLOWER(p2);
if ( (p0_lc == 'i' && p1_lc == 'n' && p2_lc == 'c') /*, Inc */
|| (p0_lc == 'l' && p1_lc == 't' && p2_lc == 'd') /*, Ltd */
|| (p0_lc == 't' && p1_lc == 'h' && p2_lc == 'e') /*, The */
)
return (p[3] == '.' ? 4 : 3);
return 0; return 0;
} }