Bug 145538 - Use range based for loops
Summary: Use range based for loops
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: target:7.3.0 target:7.4.0 reviewed:2022
Keywords: difficultyBeginner, easyHack, skillCpp
Depends on:
Blocks: Dev-related
  Show dependency treegraph
 
Reported: 2021-11-04 08:54 UTC by Hossein
Modified: 2022-06-21 13:53 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:
Regression By:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Hossein 2021-11-04 08:54:10 UTC
Since C++11, range based loops are available for iterating over a known
range of values. For example, when there is a need to process elements
of a container, range based loops are usually a good choice. They are
easy to write, read and understand.

This EasyHack is about using range based loops when it is more appropriate. This is an example where range based loop was better suited:

Use range based for loops
https://git.libreoffice.org/core/+/47728bb925b33a8fe536fed8c913a2669bf101b6

Make sure that you understand where to use reference or const reference if needed. A suggested reading:
https://blog.knatten.org/2013/10/13/prefer-using-references-with-range-based-for-loops/
Comment 1 Commit Notification 2021-11-23 12:57:39 UTC
Henrik Palomäki committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/6f435016092953478b5636fe9078866500fc7b90

tdf#145538 Use range based for loops

It will be available in 7.3.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.
Comment 2 Commit Notification 2021-11-23 13:43:41 UTC
Harjot committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/34a0f7023aad59bc054385f0593606d5d602e052

tdf#145538 Use range based for loops in EnhancedShapeDumper.cxx

It will be available in 7.3.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.
Comment 3 Commit Notification 2021-12-30 13:51:15 UTC
Ramreiso Kashung committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/7886b6a56a51cb699fb2a18d8a8dff0e224bdfb5

tdf#145538 : Using range-based for loops

It will be available in 7.4.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.
Comment 4 Commit Notification 2021-12-30 20:44:37 UTC
Ankur Khandelwal committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/96882cdec23c64974737c4833f157d54b85a129e

tdf#145538 Use range based loops

It will be available in 7.4.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.
Comment 5 Commit Notification 2022-01-12 19:14:34 UTC
dtm committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/582bf1a27c5adc6684e8d9af3805cfe40fa051d5

tdf#145538 - Use range based for loops

It will be available in 7.4.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.
Comment 6 Commit Notification 2022-01-17 19:50:41 UTC
VaibhavMalik4187 committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/e7b01e4a5a856543e85f614c82950122e9598518

tdf#145538 - Use range based for loops

It will be available in 7.4.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.
Comment 7 Commit Notification 2022-03-01 12:03:38 UTC
Deep17 committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/f63a6f2e396fa41ed1338dcec874e06159cafa9f

tdf#145538 - Use range based for loops

It will be available in 7.4.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.
Comment 8 Hossein 2022-06-21 13:53:42 UTC
Re-evaluating the EasyHack in 2022

This issue is still relevant, as there are many places in the code that range based for loops can be used.