mapwidget.qml: return early instead of doing branching

The centerOn*() functions can just return early
for invalid input, instead of branching the conditions.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
This commit is contained in:
Lubomir I. Ivanov 2017-11-27 17:13:57 +02:00
parent 1d80b08a8f
commit 837ed67d86

View file

@ -151,7 +151,8 @@ Item {
stopZoomAnimations()
if (!coordIsValid(coord)) {
console.warn("MapWidget.qml: centerOnCoordinate(): !coordIsValid()")
} else {
return
}
var newZoomOutFound = false
var zoomStored = zoomLevel
var centerStored = QtPositioning.coordinate(center.latitude, center.longitude)
@ -174,13 +175,13 @@ Item {
newZoom = zoomStored
mapAnimationZoomIn.restart()
}
}
function centerOnRectangle(topLeft, bottomRight, centerRect) {
stopZoomAnimations()
if (newCenter.latitude === 0.0 && newCenter.longitude === 0.0) {
// Do nothing
} else {
return
}
var centerStored = QtPositioning.coordinate(center.latitude, center.longitude)
var zoomStored = zoomLevel
var newZoomOutFound = false
@ -218,7 +219,6 @@ Item {
center = centerStored
mapAnimationZoomIn.restart()
}
}
function deselectMapLocation() {
stopZoomAnimations()