- /* Otherwise, build a temporary locale object, which will only
- * be instantiated in allocated storage if it does not match
- * one of the built-in static locales. This makes the common
- * usage case for newlocale, getting a C locale with predictable
- * behavior, very fast, and more importantly, fail-safe. */
- for (j=i=0; i<LC_ALL; i++) {
- if (loc && !(mask & (1<<i)))
- lm = loc->cat[i];
- else
- lm = __get_locale(i, mask & (1<<i) ? name : "");
- if (lm) j++;
- tmp.cat[i] = lm;
- }
-
- if (!j)
- return C_LOCALE;
- if (j==1 && tmp.cat[LC_CTYPE]==&__c_dot_utf8)
- return UTF8_LOCALE;
+ /* Otherwise, first see if we can use one of the builtin locales.
+ * This makes the common usage case for newlocale, getting a C locale
+ * with predictable behavior, very fast, and more importantly, fail-safe. */
+ if (!memcmp(&tmp, C_LOCALE, sizeof tmp)) return C_LOCALE;
+ if (!memcmp(&tmp, UTF8_LOCALE, sizeof tmp)) return UTF8_LOCALE;