mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-23 18:52:09 +01:00
performance: Add explicit casts for some double → other numeric type conversions
If we enable `-Wfloat-conversion`, these warn about a possible loss of precision due to an implicit conversion from `double` to some other numeric type. The warning is correct: there is a possible loss of precision here. In these instances, we don’t care, as the floating point arithmetic is being done to do some imprecise scaling or imprecise timing. A loss of precision is not a problem. So, add an explicit cast to squash the warning. Signed-off-by: Philip Withnall <pwithnall@gnome.org> Helps: #3405
This commit is contained in:
parent
b7153f5072
commit
e35cfef509
@ -169,7 +169,7 @@ run_test (PerformanceTest *test)
|
|||||||
g_print ("Uncorrected round time: %.4f msecs, correction factor %.2f\n", 1000*min_elapsed, factor);
|
g_print ("Uncorrected round time: %.4f msecs, correction factor %.2f\n", 1000*min_elapsed, factor);
|
||||||
|
|
||||||
/* Calculate number of rounds needed */
|
/* Calculate number of rounds needed */
|
||||||
num_rounds = (test_length / TARGET_ROUND_TIME) + 1;
|
num_rounds = (guint64) (test_length / TARGET_ROUND_TIME) + 1;
|
||||||
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
g_print ("Running %"G_GINT64_MODIFIER"d rounds\n", num_rounds);
|
g_print ("Running %"G_GINT64_MODIFIER"d rounds\n", num_rounds);
|
||||||
@ -528,7 +528,7 @@ test_construction_init (PerformanceTest *test,
|
|||||||
struct ConstructionTest *data = _data;
|
struct ConstructionTest *data = _data;
|
||||||
unsigned int n;
|
unsigned int n;
|
||||||
|
|
||||||
n = NUM_OBJECT_TO_CONSTRUCT * count_factor;
|
n = (unsigned int) (NUM_OBJECT_TO_CONSTRUCT * count_factor);
|
||||||
if (data->n_objects != n)
|
if (data->n_objects != n)
|
||||||
{
|
{
|
||||||
data->n_objects = n;
|
data->n_objects = n;
|
||||||
@ -650,7 +650,7 @@ test_finalization_init (PerformanceTest *test,
|
|||||||
struct ConstructionTest *data = _data;
|
struct ConstructionTest *data = _data;
|
||||||
unsigned int n;
|
unsigned int n;
|
||||||
|
|
||||||
n = NUM_OBJECT_TO_CONSTRUCT * count_factor;
|
n = (unsigned int) (NUM_OBJECT_TO_CONSTRUCT * count_factor);
|
||||||
if (data->n_objects != n)
|
if (data->n_objects != n)
|
||||||
{
|
{
|
||||||
data->n_objects = n;
|
data->n_objects = n;
|
||||||
@ -735,7 +735,7 @@ test_type_check_init (PerformanceTest *test,
|
|||||||
{
|
{
|
||||||
struct TypeCheckTest *data = _data;
|
struct TypeCheckTest *data = _data;
|
||||||
|
|
||||||
data->n_checks = factor * NUM_KILO_CHECKS_PER_ROUND;
|
data->n_checks = (unsigned int) (factor * NUM_KILO_CHECKS_PER_ROUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -851,7 +851,7 @@ test_emission_unhandled_init (PerformanceTest *test,
|
|||||||
{
|
{
|
||||||
struct EmissionTest *data = _data;
|
struct EmissionTest *data = _data;
|
||||||
|
|
||||||
data->n_checks = factor * NUM_EMISSIONS_PER_ROUND;
|
data->n_checks = (unsigned int) (factor * NUM_EMISSIONS_PER_ROUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -924,7 +924,7 @@ test_emission_handled_init (PerformanceTest *test,
|
|||||||
{
|
{
|
||||||
struct EmissionTest *data = _data;
|
struct EmissionTest *data = _data;
|
||||||
|
|
||||||
data->n_checks = factor * NUM_EMISSIONS_PER_ROUND;
|
data->n_checks = (unsigned int) (factor * NUM_EMISSIONS_PER_ROUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1008,7 +1008,7 @@ test_notify_unhandled_init (PerformanceTest *test,
|
|||||||
{
|
{
|
||||||
struct NotifyTest *data = _data;
|
struct NotifyTest *data = _data;
|
||||||
|
|
||||||
data->n_checks = factor * NUM_NOTIFY_PER_ROUND;
|
data->n_checks = (unsigned int) (factor * NUM_NOTIFY_PER_ROUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1070,7 +1070,7 @@ test_notify_handled_init (PerformanceTest *test,
|
|||||||
{
|
{
|
||||||
struct NotifyTest *data = _data;
|
struct NotifyTest *data = _data;
|
||||||
|
|
||||||
data->n_checks = factor * NUM_NOTIFY_PER_ROUND;
|
data->n_checks = (unsigned int) (factor * NUM_NOTIFY_PER_ROUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1150,7 +1150,7 @@ test_set_init (PerformanceTest *test,
|
|||||||
{
|
{
|
||||||
struct SetTest *data = _data;
|
struct SetTest *data = _data;
|
||||||
|
|
||||||
data->n_checks = factor * NUM_SET_PER_ROUND;
|
data->n_checks = (unsigned int) (factor * NUM_SET_PER_ROUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1228,7 +1228,7 @@ test_get_init (PerformanceTest *test,
|
|||||||
{
|
{
|
||||||
struct GetTest *data = _data;
|
struct GetTest *data = _data;
|
||||||
|
|
||||||
data->n_checks = factor * NUM_GET_PER_ROUND;
|
data->n_checks = (unsigned int) (factor * NUM_GET_PER_ROUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1303,7 +1303,7 @@ test_refcount_init (PerformanceTest *test,
|
|||||||
{
|
{
|
||||||
struct RefcountTest *data = _data;
|
struct RefcountTest *data = _data;
|
||||||
|
|
||||||
data->n_checks = factor * NUM_KILO_REFS_PER_ROUND;
|
data->n_checks = (unsigned int) (factor * NUM_KILO_REFS_PER_ROUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
x
Reference in New Issue
Block a user