Review Request 116886: Refactor private variables of KCompletion

David Gil Oliva davidgiloliva at gmail.com
Wed Mar 19 22:36:17 UTC 2014



> On March 19, 2014, 11:55 a.m., Frank Reininghaus wrote:
> > src/kcompletion_p.h, line 338
> > <https://git.reviewboard.kde.org/r/116886/diff/2/?file=255262#file255262line338>
> >
> >     This is not strictly related to your changes, but it looks a bit unusual to have one plain bool and two bool bitfields next to each other. Making all bools a bitfield won't make much difference now though because the compiler will always use more memory for this class in order to preserve the 4-byte or 8-byte alignment.
> >     
> >     Another alignment-related issue is caused by your patch though: on a 64-bit system, moving the int member away from the bools will most likely increase sizeof(KCompletionPrivate) by 8 bytes because the compiler will add some padding to both in order to preserve the alignment of the neigbouring pointers.
> >     
> >     It might not make a big difference because it's probably unusual to create thousands of KCompletionPrivate instances, but still, it seems unnecessary.
> >     
> >     If one really wanted to make use of bitfields to save memory here, one could make 'order' a bitfield and move it next to the bools.

"This is not strictly related to your changes, but it looks a bit unusual to have one plain bool and two bool bitfields next to each other."

I know, but I can't change it without changing the method 'void findAllCompletions(const QString &, KCompletionMatchesWrapper *matches,   bool &hasMultipleMatches) const' in kcompletion_p.h. The boolean parameter is passed as a reference and therefore the compiler complains it can't be a bitfield. That method is doomed to be moved elsewhere. Then I will change that bool to bitfield.

"If one really wanted to make use of bitfields to save memory here, one could make 'order' a bitfield and move it next to the bools."

Ok, let's see if I do it well :-)


- David


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/116886/#review53410
-----------------------------------------------------------


On March 18, 2014, 11:01 p.m., David Gil Oliva wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://git.reviewboard.kde.org/r/116886/
> -----------------------------------------------------------
> 
> (Updated March 18, 2014, 11:01 p.m.)
> 
> 
> Review request for KDE Frameworks.
> 
> 
> Repository: kcompletion
> 
> 
> Description
> -------
> 
> Refactor private variables of KCompletion
> 
> Also: reorder variables declaration to avoid padding
> 
> 
> Diffs
> -----
> 
>   src/kcompletion_p.h e3fad26 
>   src/kcompletion.cpp 7396029 
> 
> Diff: https://git.reviewboard.kde.org/r/116886/diff/
> 
> 
> Testing
> -------
> 
> It builds. Autotests pass.
> 
> 
> Thanks,
> 
> David Gil Oliva
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20140319/3f3321ee/attachment.html>


More information about the Kde-frameworks-devel mailing list