Browse Source

ENH: make regex static so it is not recomputed for each line of the cache

Bill Hoffman 20 years ago
parent
commit
a3d1de8cd2
1 changed files with 4 additions and 4 deletions
  1. 4 4
      Source/cmCacheManager.cxx

+ 4 - 4
Source/cmCacheManager.cxx

@@ -83,9 +83,9 @@ bool cmCacheManager::ParseEntry(const char* entry,
                                 std::string& value)
                                 std::string& value)
 {
 {
   // input line is:         key:type=value
   // input line is:         key:type=value
-  cmsys::RegularExpression reg("^([^:]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$");
+  static cmsys::RegularExpression reg("^([^:]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$");
   // input line is:         "key":type=value
   // input line is:         "key":type=value
-  cmsys::RegularExpression regQuoted("^\"([^\"]*)\"=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$");
+  static cmsys::RegularExpression regQuoted("^\"([^\"]*)\"=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$");
   bool flag = false;
   bool flag = false;
   if(regQuoted.find(entry))
   if(regQuoted.find(entry))
     {
     {
@@ -120,9 +120,9 @@ bool cmCacheManager::ParseEntry(const char* entry,
                                 CacheEntryType& type)
                                 CacheEntryType& type)
 {
 {
   // input line is:         key:type=value
   // input line is:         key:type=value
-  cmsys::RegularExpression reg("^([^:]*):([^=]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$");
+  static cmsys::RegularExpression reg("^([^:]*):([^=]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$");
   // input line is:         "key":type=value
   // input line is:         "key":type=value
-  cmsys::RegularExpression regQuoted("^\"([^\"]*)\":([^=]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$");
+  static cmsys::RegularExpression regQuoted("^\"([^\"]*)\":([^=]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$");
   bool flag = false;
   bool flag = false;
   if(regQuoted.find(entry))
   if(regQuoted.find(entry))
     {
     {