File tree 1 file changed +13
-0
lines changed
1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -151,6 +151,13 @@ typedef struct
151
151
static MemoryContext CollationCacheContext = NULL ;
152
152
static collation_cache_hash * CollationCache = NULL ;
153
153
154
+ /*
155
+ * The collation cache is often accessed repeatedly for the same collation, so
156
+ * remember the last one used.
157
+ */
158
+ static Oid last_collation_cache_oid = InvalidOid ;
159
+ static pg_locale_t last_collation_cache_locale = NULL ;
160
+
154
161
#if defined(WIN32 ) && defined(LC_MESSAGES )
155
162
static char * IsoLocaleName (const char * );
156
163
#endif
@@ -1570,6 +1577,9 @@ pg_newlocale_from_collation(Oid collid)
1570
1577
if (collid == DEFAULT_COLLATION_OID )
1571
1578
return & default_locale ;
1572
1579
1580
+ if (last_collation_cache_oid == collid )
1581
+ return last_collation_cache_locale ;
1582
+
1573
1583
cache_entry = lookup_collation_cache (collid );
1574
1584
1575
1585
if (cache_entry -> locale == 0 )
@@ -1695,6 +1705,9 @@ pg_newlocale_from_collation(Oid collid)
1695
1705
cache_entry -> locale = resultp ;
1696
1706
}
1697
1707
1708
+ last_collation_cache_oid = collid ;
1709
+ last_collation_cache_locale = cache_entry -> locale ;
1710
+
1698
1711
return cache_entry -> locale ;
1699
1712
}
1700
1713
You can’t perform that action at this time.
0 commit comments