From: borutr Date: Sun, 15 Jun 2003 19:00:33 +0000 (+0000) Subject: reimplemented function inExcludeList() by using sets instead fixed width array of... X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=a5a286c47796b77807a0f0c12c1a3d1c447435a8;p=fw%2Fsdcc reimplemented function inExcludeList() by using sets instead fixed width array of pointers git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2699 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/src/ds390/gen.c b/src/ds390/gen.c index c412390a..129900af 100644 --- a/src/ds390/gen.c +++ b/src/ds390/gen.c @@ -2832,22 +2832,22 @@ resultRemat (iCode * ic) /*-----------------------------------------------------------------*/ /* inExcludeList - return 1 if the string is in exclude Reg list */ /*-----------------------------------------------------------------*/ +static int +regsCmp(void *p1, void *p2) +{ + return (STRCASECMP((char *)p1, (char *)(p2)) == 0); +} + static bool inExcludeList (char *s) { - int i = 0; + const char *p = setFirstItem(options.excludeRegsSet); - if (options.excludeRegs[i] && - STRCASECMP (options.excludeRegs[i], "none") == 0) + if (p == NULL || STRCASECMP(p, "none") == 0) return FALSE; - for (i = 0; options.excludeRegs[i]; i++) - { - if (options.excludeRegs[i] && - STRCASECMP (s, options.excludeRegs[i]) == 0) - return TRUE; - } - return FALSE; + + return isinSetWith(options.excludeRegsSet, s, regsCmp); } /*-----------------------------------------------------------------*/ diff --git a/src/mcs51/gen.c b/src/mcs51/gen.c index 529be381..235eeeb2 100644 --- a/src/mcs51/gen.c +++ b/src/mcs51/gen.c @@ -2219,22 +2219,22 @@ resultRemat (iCode * ic) /*-----------------------------------------------------------------*/ /* inExcludeList - return 1 if the string is in exclude Reg list */ /*-----------------------------------------------------------------*/ +static int +regsCmp(void *p1, void *p2) +{ + return (STRCASECMP((char *)p1, (char *)(p2)) == 0); +} + static bool inExcludeList (char *s) { - int i = 0; + const char *p = setFirstItem(options.excludeRegsSet); - if (options.excludeRegs[i] && - STRCASECMP (options.excludeRegs[i], "none") == 0) + if (p == NULL || STRCASECMP(p, "none") == 0) return FALSE; - for (i = 0; options.excludeRegs[i]; i++) - { - if (options.excludeRegs[i] && - STRCASECMP (s, options.excludeRegs[i]) == 0) - return TRUE; - } - return FALSE; + + return isinSetWith(options.excludeRegsSet, s, regsCmp); } /*-----------------------------------------------------------------*/