From 5f2628201cd1ad8d9129011d923f2923b8b4b3b9 Mon Sep 17 00:00:00 2001 From: "David A. Madore" Date: Thu, 29 Apr 2010 01:03:38 +0200 Subject: This is Java: we have the Math.min and Math.max functions! --- src/org/madore/android/unicodeMap/UnicodeCharacter.java | 6 +++--- src/org/madore/android/unicodeMap/UnicodeDatabase.java | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/org') diff --git a/src/org/madore/android/unicodeMap/UnicodeCharacter.java b/src/org/madore/android/unicodeMap/UnicodeCharacter.java index f3ff6d1..f399d2b 100644 --- a/src/org/madore/android/unicodeMap/UnicodeCharacter.java +++ b/src/org/madore/android/unicodeMap/UnicodeCharacter.java @@ -266,9 +266,9 @@ public class UnicodeCharacter implements UnicodeDisplayable { return ( codePoint>=this.from && codePointthis.to)?this.to:to; - return (to0-from0>0) ? to0-from0 : 0; + int from0 = Math.max(this.from, from); + int to0 = Math.min(this.to, to); + return Math.max(to0-from0, 0); } public boolean inside(int from, int to) { return ( from >= this.from && to <= this.to ); diff --git a/src/org/madore/android/unicodeMap/UnicodeDatabase.java b/src/org/madore/android/unicodeMap/UnicodeDatabase.java index efdf5eb..d95501d 100644 --- a/src/org/madore/android/unicodeMap/UnicodeDatabase.java +++ b/src/org/madore/android/unicodeMap/UnicodeDatabase.java @@ -267,8 +267,8 @@ public class UnicodeDatabase { = new ArrayList(rng.interCount(from, to)); else muchAnnoyance = true; - int from0 = (fromrng.getTo())?rng.getTo():to; + int from0 = Math.max(rng.getFrom(), from); + int to0 = Math.min(rng.getTo(), to); Iterable rangeIt = new SpecialRangeIterable(rng, from0, to0); for ( UnicodeCharacter ch : rangeIt ) -- cgit v1.2.3