https://bugs.documentfoundation.org/show_bug.cgi?id=148251
Bug ID: 148251
Summary: Use std::swap instead of using temporary values,
proposed beginner easyHack
Product: LibreOffice
Version: 7.4.0.0 alpha0+ Master
Hardware: All
OS: All
Status: UNCONFIRMED
Severity: normal
Priority: medium
Component: LibreOffice
Assignee: [email protected]
Reporter: [email protected]
Description:
There's places in code where a swap between two variables happens like this:
T temp = a;
a = b;
b = temp;
There's no need to clutter code with 3 lines where just one is enough:
std::swap(a, b);
Furthermore, std::swap uses move semantics which can improve performance for
big data members.
How to find occurrences:
You can use this regex that currently finds 78 results:
(\w+)[\n\r\s]+(\w+)[\n\r\s]+=[\n\r\s]+(\w+);[\n\r\s]+(\3)[\n\r\s]+=[\n\r\s]+(\w+);[\n\r\s]+(\5)[\n\r\s]+=[\n\r\s]+(\2)
[\n\r\s]+ matches newlines and spaces. This exhaustively searches for any weird
combination of spaces between the type/variable names/semicolons
See this https://gerrit.libreoffice.org/c/core/+/132194 for an example
Steps to Reproduce:
-
Actual Results:
-
Expected Results:
-
Reproducible: Always
User Profile Reset: No
Additional Info:
-
--
You are receiving this mail because:
You are the assignee for the bug.