Author Topic: About the F() macro and wxString::Format  (Read 2842 times)

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
About the F() macro and wxString::Format
« on: May 11, 2022, 04:20:25 pm »
I see this commit:

https://sourceforge.net/p/codeblocks/code/12807/

I remember that we have discussed several years ago, that the F() macro is not thread safe, it uses a global variable. So, maybe we will use wxString::Format to replace F()?
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1553
Re: About the F() macro and wxString::Format
« Reply #1 on: May 11, 2022, 04:42:25 pm »
I think the F() macro currently has no advantage over wxString::Format() and complicates the calls unnecesarily, forcing usage of wx_str().
The thread-safe part is one important reason to ditch it.

Also, calls to wxT() and _T() should be removed. There are a lot of code like this:
Code
if (String[n] == wxT('P'))
that creates two temporary wxString and compares them, while this:
Code
if (String[n] == 'P')
does a direct wxChar comparation.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: About the F() macro and wxString::Format
« Reply #2 on: May 12, 2022, 03:33:14 am »
Miguel Gimenez, I agree with your opinion.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.