Change comparison to use int instead of double (#1758)

This allows the example to remain simple well not misleading a beginner
such a comparison is safe. Including an epsilon comparison or something
similar would overly complicate this example.

Co-authored-by: Martin O'Shea <martin.oshea@native-instruments.com>
This commit is contained in:
Martin 2021-03-11 20:05:59 +01:00 committed by GitHub
parent 1caef9a7f1
commit ffeca2a254
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -13945,10 +13945,10 @@ Although `cached_computation` works perfectly in a single-threaded environment,
##### Example, good
struct ComputationCache {
double cached_x = 0.0;
int cached_x = 0;
double cached_result = COMPUTATION_OF_ZERO;
double compute(double x) {
double compute(int x) {
if (cached_x != x) {
cached_x = x;
cached_result = computation(x);