Switch to lists instead of allocating new arrays each time.
This commit is contained in:
parent
2210a101d0
commit
8d91035a05
@ -1,4 +1,4 @@
|
|||||||
#Wed, 22 Jun 2022 18:18:39 +0000
|
#Wed, 22 Jun 2022 18:35:38 +0000
|
||||||
|
|
||||||
|
|
||||||
/workspaces/jinput2.10=
|
/workspaces/jinput2.10=
|
||||||
|
Binary file not shown.
Binary file not shown.
BIN
dist/jinput-with-sources.jar
vendored
BIN
dist/jinput-with-sources.jar
vendored
Binary file not shown.
BIN
dist/jinput.jar
vendored
BIN
dist/jinput.jar
vendored
Binary file not shown.
@ -107,6 +107,8 @@ class DefaultControllerEnvironment extends ControllerEnvironment {
|
|||||||
*/
|
*/
|
||||||
private ArrayList<Controller> controllers;
|
private ArrayList<Controller> controllers;
|
||||||
private ArrayList<Controller> newControllers;
|
private ArrayList<Controller> newControllers;
|
||||||
|
private ArrayList<Boolean> controllerChecklist;
|
||||||
|
private ArrayList<Boolean> newControllerChecklist;
|
||||||
|
|
||||||
private Collection loadedPlugins = new ArrayList();
|
private Collection loadedPlugins = new ArrayList();
|
||||||
private ArrayList<ControllerEnvironment> environments = new ArrayList<ControllerEnvironment>();
|
private ArrayList<ControllerEnvironment> environments = new ArrayList<ControllerEnvironment>();
|
||||||
@ -115,6 +117,9 @@ class DefaultControllerEnvironment extends ControllerEnvironment {
|
|||||||
* Public no-arg constructor.
|
* Public no-arg constructor.
|
||||||
*/
|
*/
|
||||||
public DefaultControllerEnvironment() {
|
public DefaultControllerEnvironment() {
|
||||||
|
newControllers = new ArrayList<Controller>();
|
||||||
|
controllerChecklist = new ArrayList<Boolean>();
|
||||||
|
newControllerChecklist = new ArrayList<Boolean>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -125,7 +130,6 @@ class DefaultControllerEnvironment extends ControllerEnvironment {
|
|||||||
if (controllers == null) {
|
if (controllers == null) {
|
||||||
// Controller list has not been scanned.
|
// Controller list has not been scanned.
|
||||||
controllers = new ArrayList<Controller>();
|
controllers = new ArrayList<Controller>();
|
||||||
newControllers = new ArrayList<Controller>();
|
|
||||||
AccessController.doPrivileged(new PrivilegedAction() {
|
AccessController.doPrivileged(new PrivilegedAction() {
|
||||||
public Object run() {
|
public Object run() {
|
||||||
scanControllers();
|
scanControllers();
|
||||||
@ -200,27 +204,25 @@ class DefaultControllerEnvironment extends ControllerEnvironment {
|
|||||||
public Controller[] rescanControllers() {
|
public Controller[] rescanControllers() {
|
||||||
if(!environments.isEmpty()){
|
if(!environments.isEmpty()){
|
||||||
Controller[] newScanControllers = environments.get(0).rescanControllers();
|
Controller[] newScanControllers = environments.get(0).rescanControllers();
|
||||||
boolean[] controllerChecklist = new boolean[controllers.size()];
|
|
||||||
boolean[] newControllerChecklist = new boolean[newScanControllers.length];
|
|
||||||
// Create a checklist for all controllers.
|
// Create a checklist for all controllers.
|
||||||
for(int i = 0; i < newScanControllers.length; i++){
|
for(int i = 0; i < newScanControllers.length; i++){
|
||||||
for (int j=0;j<controllerChecklist.length;j++) {
|
for (int j=0;j<controllerChecklist.size();j++) {
|
||||||
if (!controllerChecklist[j]&&((AbstractController)controllers.get(j)).equals(newScanControllers[i])) {
|
if (!controllerChecklist.get(j)&&((AbstractController)controllers.get(j)).equals(newScanControllers[i])) {
|
||||||
controllerChecklist[j]=true;
|
controllerChecklist.set(j,true);
|
||||||
newControllerChecklist[j]=true;
|
newControllerChecklist.set(j,true);
|
||||||
newControllers.add(newScanControllers[i]);
|
newControllers.add(newScanControllers[i]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int i=0;i<controllerChecklist.length;i++) {
|
for (int i=0;i<controllerChecklist.size();i++) {
|
||||||
if (!controllerChecklist[i]) {
|
if (!controllerChecklist.get(i)) {
|
||||||
//Remove this controller.
|
//Remove this controller.
|
||||||
fireControllerRemoved(controllers.get(i));
|
fireControllerRemoved(controllers.get(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int i=0;i<newControllerChecklist.length;i++) {
|
for (int i=0;i<newControllerChecklist.size();i++) {
|
||||||
if (!newControllerChecklist[i]) {
|
if (!newControllerChecklist.get(i)) {
|
||||||
//Add this controller.
|
//Add this controller.
|
||||||
fireControllerAdded(newScanControllers[i]);
|
fireControllerAdded(newScanControllers[i]);
|
||||||
newControllers.add(newScanControllers[i]);
|
newControllers.add(newScanControllers[i]);
|
||||||
@ -238,6 +240,8 @@ class DefaultControllerEnvironment extends ControllerEnvironment {
|
|||||||
controllers.clear();
|
controllers.clear();
|
||||||
controllers.addAll(newControllers);
|
controllers.addAll(newControllers);
|
||||||
newControllers.clear();
|
newControllers.clear();
|
||||||
|
controllerChecklist.clear();
|
||||||
|
newControllerChecklist.clear();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user