Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/native
diff options
context:
space:
mode:
authorTorbjörn Svensson2020-11-05 20:32:19 +0000
committerJonah Graham2020-11-11 19:56:04 +0000
commit8b391a7f3a914568bf6cc122d61088992763d377 (patch)
treea6403ddf29edda5f095923ec89285d530c4ac49e /native
parentd0c3b2aaffba46b84b9cc2ef21f4ccd10ad6d714 (diff)
downloadorg.eclipse.cdt-8b391a7f3a914568bf6cc122d61088992763d377.tar.gz
org.eclipse.cdt-8b391a7f3a914568bf6cc122d61088992763d377.tar.xz
org.eclipse.cdt-8b391a7f3a914568bf6cc122d61088992763d377.zip
Bug 568079: Reducing transitions from JAVA to native code (part 2)
Advapi32Util.registryGetValues() is more efficient to fetch all the values since the regiter only needs to be opened once. XXX: Due to a cycle in the dependencies we need to split this in two parts, this previous commit handles the core.native API change and this commit handles the use of the new API Signed-off-by: Torbjörn Svensson <azoff@svenskalinuxforeningen.se> Change-Id: I960954e332e05dfebcd0263f983bbbc6c64d46af
Diffstat (limited to 'native')
-rw-r--r--native/org.eclipse.cdt.native.serial/META-INF/MANIFEST.MF2
-rw-r--r--native/org.eclipse.cdt.native.serial/src/org/eclipse/cdt/serial/SerialPort.java22
2 files changed, 5 insertions, 19 deletions
diff --git a/native/org.eclipse.cdt.native.serial/META-INF/MANIFEST.MF b/native/org.eclipse.cdt.native.serial/META-INF/MANIFEST.MF
index 52b48f6b3df..1614f278e13 100644
--- a/native/org.eclipse.cdt.native.serial/META-INF/MANIFEST.MF
+++ b/native/org.eclipse.cdt.native.serial/META-INF/MANIFEST.MF
@@ -8,4 +8,4 @@ Bundle-RequiredExecutionEnvironment: JavaSE-11
Export-Package: org.eclipse.cdt.serial
Automatic-Module-Name: org.eclipse.cdt.native.serial
Bundle-Localization: plugin
-Require-Bundle: org.eclipse.cdt.core.native;bundle-version="6.0.100"
+Require-Bundle: org.eclipse.cdt.core.native;bundle-version="[6.1.0,7.0.0)"
diff --git a/native/org.eclipse.cdt.native.serial/src/org/eclipse/cdt/serial/SerialPort.java b/native/org.eclipse.cdt.native.serial/src/org/eclipse/cdt/serial/SerialPort.java
index 80970dafe25..a305eb30cd1 100644
--- a/native/org.eclipse.cdt.native.serial/src/org/eclipse/cdt/serial/SerialPort.java
+++ b/native/org.eclipse.cdt.native.serial/src/org/eclipse/cdt/serial/SerialPort.java
@@ -19,11 +19,9 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.ref.WeakReference;
-import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
-import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
@@ -258,22 +256,10 @@ public class SerialPort {
} else if (osName.startsWith("Windows")) { //$NON-NLS-1$
final WindowsRegistry registry = WindowsRegistry.getRegistry();
if (registry != null) {
- final String subKey = "HARDWARE\\DEVICEMAP\\SERIALCOMM"; //$NON-NLS-1$
-
- List<String> ports = new ArrayList<>();
- int i = 0;
- String valueName = null;
- String value = null;
- do {
- valueName = registry.getLocalMachineValueName(subKey, i++);
- if (valueName != null) {
- value = registry.getLocalMachineValue(subKey, valueName);
- if (value != null) {
- ports.add(value);
- }
- }
- } while (valueName != null && value != null);
- return ports.toArray(new String[ports.size()]);
+ return registry.getLocalMachineValues("HARDWARE\\DEVICEMAP\\SERIALCOMM").values().stream() //$NON-NLS-1$
+ .filter(String.class::isInstance) // Should only be strings here, but lets be safe
+ .map(String.class::cast) //
+ .toArray(String[]::new);
}
}
return new String[0];

Back to the top