[libchamplain/wrap: 8/14] Optimize x_to_wrap_x()
- From: Jiří Techet <jiritechet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libchamplain/wrap: 8/14] Optimize x_to_wrap_x()
- Date: Sun, 13 Apr 2014 16:03:55 +0000 (UTC)
commit a8407f7d9dacbb248e1048841d4f3c5e5fa97a40
Author: Jiří Techet <techet gmail com>
Date: Sun Apr 13 01:16:46 2014 +0200
Optimize x_to_wrap_x()
champlain/champlain-view.c | 14 ++++++--------
1 files changed, 6 insertions(+), 8 deletions(-)
---
diff --git a/champlain/champlain-view.c b/champlain/champlain-view.c
index 9602fe2..73c46ae 100644
--- a/champlain/champlain-view.c
+++ b/champlain/champlain-view.c
@@ -266,15 +266,13 @@ static ChamplainBoundingBox *get_bounding_box (ChamplainView *view,
gdouble x,
gdouble y);
-static inline gint
-x_to_wrap_x (gint x, gint width) {
- while (x < 0)
- x += width;
-
- while (x >= width)
- x -= width;
- return x;
+static gint
+x_to_wrap_x (gint x, gint width) {
+ if (x < 0)
+ x += (-x / width + 1) * width;
+
+ return x % width;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]