Review Request 113162: fix invalid type conversion (char vs. const char)

Jiří Pinkava j-pi at seznam.cz
Wed Oct 9 14:44:36 BST 2013



> On Oct. 9, 2013, 11:24 a.m., Jan Kundrát wrote:
> > You can even make it a `const char * const` to communicate that the actual pointer itself is const, too.
> > 
> > That said, in this particular case I would just use a hardcoded "HOME" in both getenv and setenv for simplicity, but I'm not a kdelibs developer.
> 
> Jiří Pinkava wrote:
>     insert string "HOME" directly is not good idea (in general) because optimalizator is forced (by C/C++ standard) to allocate two strings in memory (even if they are identical).
>     
>     the mous used construction is
>     
>     const char home[] = "HOME";
> 
> Jan Kundrát wrote:
>     I would appreciate a citation here. http://stackoverflow.com/questions/690176/c-c-optimization-of-pointers-to-string-constants disagrees with what you're claiming, and contains an example to make a point.

Thansk for correction.

I would recomand still use previous form, because it (in generel) does not allow typo when the same text should used.


- Jiří


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://git.reviewboard.kde.org/r/113162/#review41425
-----------------------------------------------------------


On Oct. 7, 2013, 7:40 p.m., Jiří Pinkava wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> http://git.reviewboard.kde.org/r/113162/
> -----------------------------------------------------------
> 
> (Updated Oct. 7, 2013, 7:40 p.m.)
> 
> 
> Review request for kdelibs.
> 
> 
> Repository: kdelibs
> 
> 
> Description
> -------
> 
> oneline fix: char -> const char
> 
> 
> Diffs
> -----
> 
>   kdecore/auth/kauthhelpersupport.cpp f99b64d 
> 
> Diff: http://git.reviewboard.kde.org/r/113162/diff/
> 
> 
> Testing
> -------
> 
> 
> Thanks,
> 
> Jiří Pinkava
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20131009/ee3c45be/attachment.htm>


More information about the kde-core-devel mailing list