diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2021-10-11 17:32:31 +0200 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2021-10-13 11:50:02 +0200 |
commit | 53d2deca802922aa70d574c9b60c028abf44987f (patch) | |
tree | e65eadaaca4513cefc0240aacf383161158e9419 /src/charts/axis/chartaxiselement.cpp | |
parent | 56fa18c2a493ed5db6b53841072d12950ac634ab (diff) |
Use ratios of natural logs rather than to base ten
Natural log is marginally cheaper to compute and a ratio of logs, to a
given base, doesn't actually depend on the base; log(a)/log(b) is the
logarithm of a to base b.
Tidy up some duplication into a use of a ternary expression to
simplify one use of this, in the process.
Change-Id: Ic91dc0b4e9255f20f2f6e3d71c32a37f759d623d
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Diffstat (limited to 'src/charts/axis/chartaxiselement.cpp')
-rw-r--r-- | src/charts/axis/chartaxiselement.cpp | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/src/charts/axis/chartaxiselement.cpp b/src/charts/axis/chartaxiselement.cpp index 1155257b..692400ea 100644 --- a/src/charts/axis/chartaxiselement.cpp +++ b/src/charts/axis/chartaxiselement.cpp @@ -555,12 +555,7 @@ QStringList ChartAxisElement::createLogValueLabels(qreal min, qreal max, qreal b if (max <= min || ticks < 1) return labels; - int firstTick; - if (base > 1) - firstTick = qCeil(std::log10(min) / std::log10(base)); - else - firstTick = qCeil(std::log10(max) / std::log10(base)); - + const int firstTick = qCeil(qLn(base > 1 ? min : max) / qLn(base)); if (format.isEmpty()) { int n = 0; if (ticks > 1) |