Skip to content

Commit c0db1bf

Browse files
Pass arguments by reference and make arguments const where possible.
1 parent d6850d9 commit c0db1bf

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

MoonPhase.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#include "MoonPhase.h"
22
#include <inttypes.h>
33

4-
MoonPhase::moonData MoonPhase::getInfo( const int32_t year, const int32_t month, const int32_t day, const double hour )
4+
MoonPhase::moonData MoonPhase::getInfo( const int32_t &year, const int32_t &month, const int32_t &day, const double &hour )
55
{
6-
/*
7-
Calculates the phase of the moon at the given epoch.
8-
returns the moon percentage that is lit as a real number (0-1)
9-
*/
6+
/*
7+
Calculates the phase of the moon at the given epoch.
8+
returns the moon percentage that is lit as a real number (0-1)
9+
*/
1010
moonData returnValue;
1111
double j = _Julian(year, month, (double)day + hour / 24.0) - 2444238.5;
1212
double ls = _sun_position(j);
@@ -18,7 +18,7 @@ MoonPhase::moonData MoonPhase::getInfo( const int32_t year, const int32_t month,
1818
return returnValue;
1919
}
2020

21-
double MoonPhase::_Julian( int32_t year, int32_t month, double day )
21+
double MoonPhase::_Julian( int32_t year, int32_t month, const double &day )
2222
{
2323
int32_t b, c, e;
2424
b = 0;
@@ -37,7 +37,7 @@ double MoonPhase::_Julian( int32_t year, int32_t month, double day )
3737
return b + c + e + day + 1720994.5;
3838
}
3939

40-
double MoonPhase::_sun_position( const double j )
40+
double MoonPhase::_sun_position( const double &j )
4141
{
4242
double n, x, e, l, dl, v;
4343
int32_t i;
@@ -59,7 +59,7 @@ double MoonPhase::_sun_position( const double j )
5959
return l;
6060
}
6161

62-
double MoonPhase::_moon_position( double j, double ls )
62+
double MoonPhase::_moon_position( const double &j, const double &ls )
6363
{
6464
double ms, l, mm, ev, sms, ae, ec;
6565
int32_t i;

MoonPhase.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ class MoonPhase
2121
double percentLit;
2222
};
2323

24-
moonData getInfo( const int32_t year, const int32_t month, const int32_t day, const double hour );
24+
moonData getInfo( const int32_t &year, const int32_t &month, const int32_t &day, const double &hour );
2525

2626
private:
2727

28-
double _Julian( int32_t year, int32_t month, double day );
28+
double _Julian( int32_t year, int32_t month, const double &day );
2929

30-
double _sun_position( const double j );
30+
double _sun_position( const double &j );
3131

32-
double _moon_position( double j, double ls );
32+
double _moon_position( const double &j, const double &ls );
3333
};
3434
#endif

0 commit comments

Comments
 (0)