performance optimization - use empty array

This commit is contained in:
Egor Ushakov
2018-03-06 17:13:52 +03:00
parent 4fa5151dc1
commit 0ef615bb31
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.debugger.impl;
import com.intellij.debugger.engine.DebugProcess;
@@ -31,7 +17,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
/**
@@ -119,21 +104,10 @@ public class ClassLoadingUtils {
}
private static ArrayReference createURLArray(EvaluationContext context)
throws EvaluateException, InvalidTypeException, ClassNotLoadedException {
DebugProcess process = context.getDebugProcess();
ArrayType arrayType = (ArrayType)process.findClass(context, "java.net.URL[]", context.getClassLoader());
ArrayReference arrayRef = arrayType.newInstance(1);
throws EvaluateException {
ArrayType arrayType = (ArrayType)context.getDebugProcess().findClass(context, "java.net.URL[]", context.getClassLoader());
ArrayReference arrayRef = arrayType.newInstance(0);
DebuggerUtilsEx.keep(arrayRef, context);
ClassType classType = (ClassType)process.findClass(context, "java.net.URL", context.getClassLoader());
VirtualMachineProxyImpl proxy = (VirtualMachineProxyImpl)process.getVirtualMachineProxy();
StringReference url = proxy.mirrorOf("file:a");
DebuggerUtilsEx.keep(url, context);
ObjectReference reference = process.newInstance(context,
classType,
classType.concreteMethodByName(JVMNameUtil.CONSTRUCTOR_NAME, "(Ljava/lang/String;)V"),
Collections.singletonList(url));
DebuggerUtilsEx.keep(reference, context);
arrayRef.setValues(Collections.singletonList(reference));
return arrayRef;
}