diff options
author | Ed Merks | 2015-11-20 09:26:06 +0000 |
---|---|---|
committer | Thomas Watson | 2015-12-01 15:27:34 +0000 |
commit | 18ce78ca78bcf8239b3325c850e75de5d32353d5 (patch) | |
tree | 75cc109768543794d1ced840523c84e1043b3ec2 /bundles/org.eclipse.osgi/osgi | |
parent | 2ed8a30003a6d69ee0fa3fd89314a40e4637b528 (diff) | |
download | rt.equinox.framework-18ce78ca78bcf8239b3325c850e75de5d32353d5.tar.gz rt.equinox.framework-18ce78ca78bcf8239b3325c850e75de5d32353d5.tar.xz rt.equinox.framework-18ce78ca78bcf8239b3325c850e75de5d32353d5.zip |
Bug 482643 The performance of FilterImpl.matches(Map) can be improved.I20151203-1230I20151203-0800I20151201-1100
Change-Id: I7d0f1697f17fafd93cd92aad089e67ac6ea17398
Signed-off-by: Ed Merks <ed.merks@gmail.com>
Diffstat (limited to 'bundles/org.eclipse.osgi/osgi')
-rw-r--r-- | bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/FrameworkUtil.java | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/FrameworkUtil.java b/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/FrameworkUtil.java index e93d15cef..d0ff36f16 100644 --- a/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/FrameworkUtil.java +++ b/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/FrameworkUtil.java @@ -734,6 +734,9 @@ public class FrameworkUtil { if (value1 instanceof String) { return compare_String(operation, (String) value1, value2); } + if (value1 instanceof Version) { + return compare_Version(operation, (Version) value1, value2); + } Class<?> clazz = value1.getClass(); if (clazz.isArray()) { @@ -1213,6 +1216,31 @@ public class FrameworkUtil { return false; } + private boolean compare_Version(int operation, Version value1, Object value2) { + if (operation == SUBSTRING) { + return false; + } + try { + Version version2 = Version.valueOf((String) value2); + switch (operation) { + case APPROX : + case EQUAL : { + return value1.compareTo(version2) == 0; + } + case GREATER : { + return value1.compareTo(version2) >= 0; + } + case LESS : { + return value1.compareTo(version2) <= 0; + } + } + } catch (Exception e) { + // if the valueOf or compareTo method throws an exception + return false; + } + return false; + } + private boolean compare_Unknown(int operation, Object value1, Object value2) { if (operation == SUBSTRING) { return false; |