Skip to content

Commit 3eb4248

Browse files
authored
Use Files.readString instead of Files.readAllBytes (#5428)
The former avoids creating a copy of byte array, so it's slightly more performant
1 parent 4a2c330 commit 3eb4248

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

vertx-core/src/main/java/io/vertx/core/impl/HostnameResolver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ private static Pattern resolvOption(String regex) {
6161
File f = new File("/etc/resolv.conf");
6262
try {
6363
if (f.exists() && f.isFile()) {
64-
String conf = new String(Files.readAllBytes(f.toPath()));
64+
String conf = Files.readString(f.toPath());
6565
int ndotsOption = parseNdotsOptionFromResolvConf(conf);
6666
if (ndotsOption != -1) {
6767
ndots = ndotsOption;

vertx-core/src/main/java/io/vertx/core/impl/verticle/JavaSourceContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public String getClassName() {
6767
*/
6868
private static String parsePackage(File file) {
6969
try {
70-
String source = new String(Files.readAllBytes(file.toPath()), StandardCharsets.UTF_8);
70+
String source = Files.readString(file.toPath());
7171
// http://stackoverflow.com/questions/1657066/java-regular-expression-finding-comments-in-code
7272
source = source.replaceAll( "//.*|(\"(?:\\\\[^\"]|\\\\\"|.)*?\")|(?s)/\\*.*?\\*/", "$1 " );
7373
for (String line : source.split("\\r?\\n")) {

0 commit comments

Comments
 (0)