diff options
author | Aaron Franke <arnfranke@yahoo.com> | 2019-08-04 20:31:26 -0700 |
---|---|---|
committer | Aaron Franke <arnfranke@yahoo.com> | 2019-08-04 20:38:38 -0700 |
commit | a9c10450bd79e862ac1d35576cba30a8425d7e0b (patch) | |
tree | ba8d93a3a5cabc7e108169f4aa05a4176bd8c105 /modules/mono | |
parent | 7126654eafc5a50a782bfbcdcfcb243807662eab (diff) |
[Core] [Mono] Optimize Wrap functions
Use is_zero_approx(), avoid a negative, and also rename "rng" to "range".
Diffstat (limited to 'modules/mono')
-rw-r--r-- | modules/mono/glue/Managed/Files/Mathf.cs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/modules/mono/glue/Managed/Files/Mathf.cs b/modules/mono/glue/Managed/Files/Mathf.cs index 6c1a51fcf9..15adf0a13b 100644 --- a/modules/mono/glue/Managed/Files/Mathf.cs +++ b/modules/mono/glue/Managed/Files/Mathf.cs @@ -336,14 +336,14 @@ namespace Godot public static int Wrap(int value, int min, int max) { - int rng = max - min; - return rng != 0 ? min + ((value - min) % rng + rng) % rng : min; + int range = max - min; + return range == 0 ? min : min + ((value - min) % range + range) % range; } public static real_t Wrap(real_t value, real_t min, real_t max) { - real_t rng = max - min; - return !IsEqualApprox(rng, default(real_t)) ? min + ((value - min) % rng + rng) % rng : min; + real_t range = max - min; + return IsZeroApprox(range) ? min : min + ((value - min) % range + range) % range; } } } |