User forums > General (but related to Code::Blocks)

wxWidgets 3.1.5

<< < (5/7) > >>

oBFusCATed:

--- Quote from: gd_on on March 14, 2021, 10:51:48 am ---Why do you say wxEmptyString should be avoided ?

--- End quote ---
Because it is more expensive probably.
I'm seeing lots of commits in wx where they are removing wxT and they are replacing wxEmptyString with wxString().

sodev:
wxEmptyString is just a wxChar*, this might lead to some surprises in certain situations, but otherwise it might be a bit faster than wxString().

oBFusCATed:
sodev: Why faster? wxString() is the fastest possible way to initialize an empty string. The wxString(wxChar *) is something that should work for actual strings.

gd_on:
Is speed a real problem in that case ?
And in the official documentation :

--- Code: ---wxString wxEmptyString

The global wxString instance of an empty string.

Used extensively in the entire wxWidgets API.

--- End code ---

I have also seen that a few guys had problem with this wxEmptyString, but the doc seem to say it's good and used extensively. It's also said it's a wxString but effectively seen as a wxChar* inside C::B (which use it more than 600 times in it's workspace  :-[). so ?? not so bad !

sodev:
oBFusCATed: It is (only?) faster in situations where no temporary wxString object gets created. Right now only comparision against wxEmptyString that use a wxChar* overload comes into my mind. Maybe also method parameter initialization benefits, depends if direct initialization of a wxString from a wxChar* is faster than copy/move-initialization from a temporary wxString.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version