Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use const_str() not _str() when generating point of use literals
to be used in str_match() / str_casematch(). As discussed with @liviuchircu here 0147baa21072c5b9#commitcomment-46519279 it saves us some code size and also should have at least some positive performance effect by not saving 2 values into memory that nobody reads.
- Loading branch information
Showing
8 changed files
with
100 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
fc22e17
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just alias the
_str()
macro to point toconst_str()
? The whole point was to make it a "tiny caster" macro, so you get your job done almost invisibly. So unit test readability was the primary concern -- I'd rather read useful stuff when reviewing unit tests, rather than "const const const const const const" all day long...fc22e17
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@liviuchircu there are still cases where _str() is quite adequate as long as it's not abused. Like when you need to convert char * or const char * into str-like struct, but you don't know the length of it. Obviously you cannot generate proper const str_const in that situation, which what makes const_str() magical. :) Plus there are lots of places where you cannot easily replace str with str_const right now without going and cleaning out all APIs in chain...
Please note that if const-portion of const_str() bothers you you can easily get around it by adding #define LSTR(x) const_str(x) at the very top of your test file, then you will be shielded from any such fallouts. :)
fc22e17
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P.S. By making this replacement I am also hoping that cases when people would just copy&paste wrong API (i.e. _str()) into their code would be reduced or even eliminated altogether.