PropertyManager's pattern only needs to be compiled once

According to Pattern docs "Instances of this class are immutable and are
safe for use by multiple concurrent threads."
This commit is contained in:
Jari Hämäläinen 2017-01-28 16:54:51 +02:00
parent 206b9c4352
commit a083481f4a

View File

@ -15,6 +15,7 @@ import java.util.regex.Pattern;
* A class which works with properties, uses getprop and setprop methods of android shell
*/
public class PropertyManager {
private final Pattern pattern = Pattern.compile("^\\[([a-zA-Z0-9_.-]*)\\]:.\\[([^\\[\\]]*)\\]");
private final JadbDevice device;
public PropertyManager(JadbDevice device) {
@ -27,8 +28,6 @@ public class PropertyManager {
}
private Map<String, String> parseProp(BufferedReader bufferedReader) throws IOException {
final Pattern pattern = Pattern.compile("^\\[([a-zA-Z0-9_.-]*)\\]:.\\[([^\\[\\]]*)\\]");
HashMap<String, String> result = new HashMap<>();
String line;