Description: In several places in the code, you may see the use of for loops to insert values from a container to another. It is more efficient and better readable if insert function is used instead of a loop. For example, consider vector. One may use insert function. The insert function is improved in C++20 which is now the baseline for LibreOffice code: std::vector<T,Allocator>::insert https://en.cppreference.com/w/cpp/container/vector/insert As an example, consider this code: std::vector<int> v {1, 2, 3}, to_insert {4, 5}; for ( size_t i = 0; i < to_insert.size(); ++i ) { v.push_back(to_insert[i]); } The loop can be written as simple as: v.insert(v.end(), to_insert.begin(), to_insert.end()); Finding Candidates: You can try finding "for" loops which consider the size or length of a container with: $ git grep -E "for ?\(" | grep -iF "size()" $ git grep -E "for ?\(" | grep -iF "length()" Note all of the found instances are suitable for the current issue. Some of them can be improved with a range-based for loop: tdf#145538 Use range based for loops https://bugs.documentfoundation.org/show_bug.cgi?id=145538 One trick to find some of the more relevant instances is searching for push_back in the next line: $ git grep -A 1 -E "for ?\(" *.cxx|grep push_back
Chris Gill committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/594554e07a952c1aaee9b96d4259bc8418b46ee9 tdf#163738 use insert function instead of for loop It will be available in 25.2.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.
Simon Chenery committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/1eb5e365212c078025b9f315f9377b8d2bef8a25 tdf#163738 use insert function instead of for loop 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.
Manish committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/28c526bc88dad00c74fba969fd76032ac94801fe tdf#163738 use insert function instead of for loop 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.
Simon Chenery committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/4cc35cf5d52b2e6f9458b27ea6b26a9ebd066af0 tdf#163738 use insert function instead of for loop in migration.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.
Stefan Dorneanu committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/6eaf9092546abe3e225ebf847e7a7fd40aa05cd7 tdf#163738 Used insert() to add multiple values in containers instead of a loop 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.
Stefan Dorneanu committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/27eb6c557e20058f4ca201e94fd9db96b881763e tdf#163738 Use insert() to add multiple values in container instead of for loop 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.