Review Request 128944: Reduce temporary allocations in the DesktopFileParser

Mark Gaiser markg85 at gmail.com
Tue Sep 20 10:15:31 UTC 2016


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



I think you might be better off (and faster) if you use http://doc.qt.io/qt-5/qbytearray.html#fromRawData which smells like a "QByteArrayRef". That saves you the conversion from QByteArray to QString (you only need to do that where you actually need it). Try it, you might save more reallocations this way :)


src/lib/plugin/desktopfileparser.cpp (line 280)
<https://git.reviewboard.kde.org/r/128944/#comment66863>

    You can optimize this one further.
    http://doc.qt.io/qt-5/qbytearray.html#fromRawData
    
    You'd just have to figure out the first position from where you want to have the string. QByteArray::lastIndexOf(...) probably helps you there.


- Mark Gaiser


On sep 19, 2016, 3:20 p.m., Aleix Pol Gonzalez wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://git.reviewboard.kde.org/r/128944/
> -----------------------------------------------------------
> 
> (Updated sep 19, 2016, 3:20 p.m.)
> 
> 
> Review request for KDE Frameworks.
> 
> 
> Repository: kcoreaddons
> 
> 
> Description
> -------
> 
> While analising plasmashell under heaptrack, one of the sore spots is temporary allocations within DesktopFileParser. This improves the situation by:
> 
> * Only converting to QString/utf8 once.
> * Using QStringRef instead of fully splitting QString to parse them.
> 
> 
> Diffs
> -----
> 
>   src/lib/plugin/desktopfileparser.cpp 2eb198d 
>   src/lib/plugin/desktopfileparser_p.h c61b297 
> 
> Diff: https://git.reviewboard.kde.org/r/128944/diff/
> 
> 
> Testing
> -------
> 
> tests still pass, plasma still works normally.
> 
> heaptrack plasmashell:
> 
> after:
>         allocations:            4169312
>         leaked allocations:     83225
>         temporary allocations:  606902
> 
> before:
>         allocations:            4680691
>         leaked allocations:     84825
>         temporary allocations:  819292
> 
> 
> Thanks,
> 
> Aleix Pol Gonzalez
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20160920/8fb5fc29/attachment.html>


More information about the Kde-frameworks-devel mailing list