Author: rfm
Date: Fri Apr  8 19:28:05 2016
New Revision: 39651

URL: http://svn.gna.org/viewcvs/gnustep?rev=39651&view=rev
Log:
Only get default locale at the point when it's actually needed

Modified:
    libs/base/trunk/Source/NSCalendarDate.m

Modified: libs/base/trunk/Source/NSCalendarDate.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/Source/NSCalendarDate.m?rev=39651&r1=39650&r2=39651&view=diff
==============================================================================
--- libs/base/trunk/Source/NSCalendarDate.m     (original)
+++ libs/base/trunk/Source/NSCalendarDate.m     Fri Apr  8 19:28:05 2016
@@ -83,6 +83,8 @@
 static NSString* (*abrIMP)(id, SEL, id);
 static NSString* (*absAbrIMP)(id, SEL, id);
 static NSString* (*dstAbrIMP)(id, SEL, id);
+
+#define LOCALE  (nil == locale ? (locale = GSPrivateDefaultLocale()) : locale)
 
 
 /*
@@ -732,13 +734,9 @@
     }
   source = [description cString];
   sourceLen = strlen(source);
-  if (locale == nil)
-    {
-      locale = GSPrivateDefaultLocale();
-    }
   if (fmt == nil)
     {
-      fmt = [locale objectForKey: NSTimeDateFormatString];
+      fmt = [LOCALE objectForKey: NSTimeDateFormatString];
       if (fmt == nil)
        {
          fmt = @"";
@@ -781,7 +779,7 @@
 
              if (c == 'c')
                {
-                 sub = [locale objectForKey: NSTimeDateFormatString];
+                 sub = [LOCALE objectForKey: NSTimeDateFormatString];
                  if (sub == nil)
                    {
                      sub = @"%X %x";
@@ -805,7 +803,7 @@
                }
              else if (c == 'X')
                {
-                 sub = [locale objectForKey: NSTimeFormatString];
+                 sub = [LOCALE objectForKey: NSTimeFormatString];
                  if (sub == nil)
                    {
                      sub = @"%H-%M-%S";
@@ -813,7 +811,7 @@
                }
              else if (c == 'x')
                {
-                 sub = [locale objectForKey: NSShortDateFormatString];
+                 sub = [LOCALE objectForKey: NSShortDateFormatString];
                  if (sub == nil)
                    {
                      sub = @"%y-%m-%d";
@@ -955,7 +953,7 @@
                      NSArray   *dayNames;
 
                      currDay = [[NSString alloc] initWithCString: tmpStr];
-                     dayNames = [locale objectForKey: NSShortWeekDayNameArray];
+                     dayNames = [LOCALE objectForKey: NSShortWeekDayNameArray];
                      for (tmpIdx = 0; tmpIdx < 7; tmpIdx++)
                        {
                          if ([[dayNames objectAtIndex: tmpIdx] isEqual:
@@ -1007,7 +1005,7 @@
                      NSArray   *dayNames;
 
                      currDay = [[NSString alloc] initWithCString: tmpStr];
-                     dayNames = [locale objectForKey: NSWeekDayNameArray];
+                     dayNames = [LOCALE objectForKey: NSWeekDayNameArray];
                      for (tmpIdx = 0; tmpIdx < 7; tmpIdx++)
                        {
                          if ([[dayNames objectAtIndex: tmpIdx] isEqual:
@@ -1051,7 +1049,7 @@
                      NSArray   *monthNames;
 
                      currMonth = [[NSString alloc] initWithCString: tmpStr];
-                     monthNames = [locale objectForKey: NSShortMonthNameArray];
+                     monthNames = [LOCALE objectForKey: NSShortMonthNameArray];
 
                      for (tmpIdx = 0; tmpIdx < 12; tmpIdx++)
                        {
@@ -1104,7 +1102,7 @@
                      NSArray   *monthNames;
 
                      currMonth = [[NSString alloc] initWithCString: tmpStr];
-                     monthNames = [locale objectForKey: NSMonthNameArray];
+                     monthNames = [LOCALE objectForKey: NSMonthNameArray];
 
                      for (tmpIdx = 0; tmpIdx < 12; tmpIdx++)
                        {
@@ -1210,7 +1208,7 @@
                      NSArray   *amPMNames;
 
                      currAMPM = [NSString stringWithUTF8String: tmpStr];
-                     amPMNames = [locale objectForKey: NSAMPMDesignation];
+                     amPMNames = [LOCALE objectForKey: NSAMPMDesignation];
 
                      /*
                       * The time addition is handled below because this
@@ -1994,24 +1992,24 @@
                break;
 
              case 'c':
-               [self _format: [locale objectForKey: NSTimeFormatString]
+               [self _format: [LOCALE objectForKey: NSTimeFormatString]
                       locale: locale
                         info: info];
                Grow(info, 1);
                info->t[info->offset++] = ' ';
-               [self _format: [locale objectForKey: NSDateFormatString]
+               [self _format: [LOCALE objectForKey: NSDateFormatString]
                       locale: locale
                         info: info];
                break;
 
              case 'X':
-               [self _format: [locale objectForKey: NSTimeFormatString]
+               [self _format: [LOCALE objectForKey: NSTimeFormatString]
                       locale: locale
                         info: info];
                break;
 
              case 'x':
-               [self _format: [locale objectForKey: NSDateFormatString]
+               [self _format: [LOCALE objectForKey: NSDateFormatString]
                       locale: locale
                         info: info];
                break;
@@ -2057,9 +2055,9 @@
                    NSArray     *months;
 
                    if (mname)
-                     months = [locale objectForKey: NSShortMonthNameArray];
+                     months = [LOCALE objectForKey: NSShortMonthNameArray];
                    else
-                     months = [locale objectForKey: NSMonthNameArray];
+                     months = [LOCALE objectForKey: NSMonthNameArray];
                    if (info->md > [months count])
                      {
                        mtag = NO;
@@ -2153,9 +2151,9 @@
                      NSArray   *days;
 
                      if (dname)
-                       days = [locale objectForKey: NSShortWeekDayNameArray];
+                       days = [LOCALE objectForKey: NSShortWeekDayNameArray];
                      else
-                       days = [locale objectForKey: NSWeekDayNameArray];
+                       days = [LOCALE objectForKey: NSWeekDayNameArray];
                      if (v < [days count])
                        {
                          NSString      *name;
@@ -2258,7 +2256,7 @@
                // Is it the am/pm indicator
              case 'p':
                {
-                 NSArray       *a = [locale objectForKey: NSAMPMDesignation];
+                 NSArray       *a = [LOCALE objectForKey: NSAMPMDesignation];
                  NSString      *ampm;
 
                  if (info->hd >= 12)
@@ -2440,10 +2438,8 @@
   NSString             *result;
   DescriptionInfo      info;
 
-  if (locale == nil)
-    locale = GSPrivateDefaultLocale();
   if (format == nil)
-    format = [locale objectForKey: NSTimeDateFormatString];
+    format = [LOCALE objectForKey: NSTimeDateFormatString];
 
   GSBreakTime(_seconds_since_ref + offset(_time_zone, self),
     &info.yd, &info.md, &info.dom, &info.hd, &info.mnd, &info.sd, &info.mil);


_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs

Reply via email to