Since C++11, STL provides means to process containers easier than before via the available functions inside <algorithm>. In tdf#153109, I have suggested using std::all_of, std::any_of and std::none_of. Here, I suggest to simplify loops via std::copy_if, find_if or remove_if: std::copy_if https://cplusplus.com/reference/algorithm/copy_if/ std::find_if https://cplusplus.com/reference/algorithm/find_if/ std::remove_if https://cplusplus.com/reference/algorithm/remove_if/ In the above links, you can find description for each of the above functions. Beyond that, you can find good tutorials for these functions. For example: Different methods to copy in C++ STL | std::copy(), copy_n(), copy_if(), copy_backward() https://www.geeksforgeeks.org/different-methods-copy-c-stl-stdcopy-copy_n-copy_if-copy_backward/ For an example of such changes inside LibreOffice code, see this commit: Simplify Sequence iterations in lingucomponent..lotuswordpro 760a377f7148e623e9e16d24e66f54a401ecb946 You have to make sure that you keep the code behavior unchanged when using the above STD functions.
I would like to work on this as I've implemented this in one of my patches. Also, can you please provide me the code pointer to start on? Thanks.
(In reply to Radhey Parekh from comment #1) > I would like to work on this as I've implemented this in one of my patches. > Also, can you please provide me the code pointer to start on? Thanks. You can use git grep to find similar patterns throughout the codebase.
This is a task that multiple people can work on at the same time, no need to assign it to a single person.
Simon Chenery committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/d9435d2759e78b716b64bfccdecaac3f3f1a0e4d tdf#153294 simplify for loop to std::find call in ImplHelper.cxx It will be available in 25.8.0. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Rafał Dobrakowski committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/b0a9be01890578d239bcb958dec33c301986519d tdf#153294 Optimize item index retrieval in Menu::GetCharacterBounds() It will be available in 25.8.0. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.