[ 
https://issues.apache.org/jira/browse/GEODE-8891?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17376885#comment-17376885
 ] 

ASF GitHub Bot commented on GEODE-8891:
---------------------------------------

mmartell commented on a change in pull request #830:
URL: https://github.com/apache/geode-native/pull/830#discussion_r665755714



##########
File path: cppcache/src/ThinClientRegion.cpp
##########
@@ -589,7 +595,7 @@ std::shared_ptr<SelectResults> ThinClientRegion::query(
   }
 
   std::string squery;
-  if (std::regex_search(predicate, PREDICATE_IS_FULL_QUERY_REGEX)) {
+  if (std::regex_search(predicate, IsFullQueryRegex::instance())) {

Review comment:
       If initializing a constant something is relatively expensive (i.e., a 
significant cost relative to its use), I'd prefer to initialize it only once, 
so I can amortize the cost of initialization.
   
   In this case, I believe mreddington is advocating just declaring it locally 
inside of functions that use it, and not worry about the cost. Although calling 
the regex CTOR is likely a small percentage of the total test time, having to 
recreate a regex that's const seems silly.
   
   If you declare the regex as a const static inside the function that uses it, 
then it will be initialized only once when the function is first used, thereby 
solving any cost concern associated with a regex CTOR. Also, C++11 guarantees 
that dynamic initialization of function-local statics is thread-safe, in case 
two threads call the function using the local regex at the same time.
   
   So my recommendation is to simply move the original 2 lines of code inside 
the function that uses it.
   ```
   
   




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


> Convert remaining singletons to Meyers pattern
> ----------------------------------------------
>
>                 Key: GEODE-8891
>                 URL: https://issues.apache.org/jira/browse/GEODE-8891
>             Project: Geode
>          Issue Type: Improvement
>          Components: native client
>            Reporter: Blake Bender
>            Priority: Major
>              Labels: pull-request-available
>
> As a developer, it is to my advantage to preemptively pay technical debt when 
> I can, especially if said debt has potentially subtle bugs.  Geode Native 
> still has several poortly-written singleton objects in legacy code, and as 
> we've just seen with the rewrite of EventId for GEODE-8887, these can 
> introduce very strange behavior in a multi-threaded app.  We need to identify 
> any of these remaining, and clean them up like we did for EventId.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to