Skip to content

Commit b60d093

Browse files
committed
Avoid copy in ColorU
1 parent b69e3e6 commit b60d093

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

pathfinder/common/color.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ ColorU::ColorU(uint32_t color) {
1212
r_ = (color << 24u) >> 24u;
1313
}
1414

15-
ColorU::ColorU(ColorF _color) {
15+
ColorU::ColorU(const ColorF& color) {
1616
// Note that the order is reversed.
17-
a_ = static_cast<uint8_t>(_color.a_ * 255.f);
18-
b_ = static_cast<uint8_t>(_color.b_ * 255.f);
19-
g_ = static_cast<uint8_t>(_color.g_ * 255.f);
20-
r_ = static_cast<uint8_t>(_color.r_ * 255.f);
17+
a_ = static_cast<uint8_t>(color.a_ * 255.f);
18+
b_ = static_cast<uint8_t>(color.b_ * 255.f);
19+
g_ = static_cast<uint8_t>(color.g_ * 255.f);
20+
r_ = static_cast<uint8_t>(color.r_ * 255.f);
2121
}
2222

2323
ColorU::ColorU(uint8_t r, uint8_t g, uint8_t b, uint8_t a) : r_(r), g_(g), b_(b), a_(a) {}

pathfinder/common/color.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ struct ColorU {
6363

6464
explicit ColorU(uint32_t color);
6565

66-
explicit ColorU(ColorF color);
66+
explicit ColorU(const ColorF& color);
6767

6868
ColorU(uint8_t r, uint8_t g, uint8_t b, uint8_t a);
6969

0 commit comments

Comments
 (0)