Skip to content

Commit 60c7746

Browse files
Added a bunch of const-specifiers.
1 parent 65bcd1b commit 60c7746

File tree

7 files changed

+341
-341
lines changed

7 files changed

+341
-341
lines changed

clock.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@ Clock::Clock() {
88
}
99

1010
std::chrono::milliseconds Clock::tick() {
11-
auto current = std::chrono::system_clock::now();
11+
const auto current = std::chrono::system_clock::now();
1212
std::chrono::milliseconds delta = std::chrono::duration_cast<std::chrono::milliseconds>(
1313
current - this->last
1414
);
1515
this->last = current;
1616
return delta;
1717
}
1818

19-
std::chrono::milliseconds Clock::tick(float fps) {
20-
auto delta = this->tick();
21-
auto min_delta = std::chrono::duration<double>(1.0 / double(fps));
22-
auto delta_delta = delta - min_delta;
19+
std::chrono::milliseconds Clock::tick(const float fps) {
20+
const auto delta = this->tick();
21+
const auto min_delta = std::chrono::duration<double>(1.0 / double(fps));
22+
const auto delta_delta = delta - min_delta;
2323
if (delta_delta > std::chrono::duration<double>(0.)) {
2424
std::this_thread::sleep_for(delta_delta);
2525
return std::chrono::duration_cast<std::chrono::milliseconds>(min_delta);

clock.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class Clock {
1212
Clock();
1313

1414
std::chrono::milliseconds tick();
15-
std::chrono::milliseconds tick(float fps);
15+
std::chrono::milliseconds tick(const float fps);
1616
};
1717

1818
#endif

color.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace SDL {
66
namespace _implementation {
77
namespace color {
8-
uchar abs(short x) {
8+
uchar abs(cshort x) {
99
if (x >= 0)
1010
return x;
1111
else
@@ -94,7 +94,7 @@ namespace SDL {
9494
this->a = a;
9595
}
9696

97-
Color::Color(uchar luminocity, cuchar a) {
97+
Color::Color(cuchar luminocity, cuchar a) {
9898
this->r = luminocity;
9999
this->g = luminocity;
100100
this->b = luminocity;
@@ -172,12 +172,12 @@ namespace SDL {
172172
return {h, s, v};
173173
}
174174

175-
Color Color::from_hsv(uchar h, uchar s, uchar v, uchar a) {
175+
Color Color::from_hsv(cuchar h, cuchar s, cuchar v, cuchar a) {
176176
if (s == 0)
177177
return {v, v, v};
178178

179179
uchar hi = float(h) / 42.5f;
180-
float f = float(h) / 42.5f - float(hi);
180+
cfloat f = float(h) / 42.5f - float(hi);
181181
uchar p = float(v) * (255.f - float(s)) / 255.f;
182182
uchar q = float(v) * (255.f - float(s) * f) / 255.f;
183183
uchar t = float(v) * (255.f - float(s) * (1.f - f)) / 255.f;
@@ -221,7 +221,7 @@ namespace SDL {
221221
return {h, s, l};
222222
}
223223

224-
Color Color::from_hsl(uchar h, uchar s, uchar l, uchar a) {
224+
Color Color::from_hsl(cuchar h, cuchar s, cuchar l, cuchar a) {
225225
if (s == 0)
226226
return {l, l, l};
227227

0 commit comments

Comments
 (0)