[FIX] Оптимизация

This commit is contained in:
Gravit 2020-09-17 19:48:11 +07:00
parent 5413ba0dd7
commit 186a749150
No known key found for this signature in database
GPG key ID: 98A079490768CCE5

View file

@ -38,19 +38,17 @@ public SeverletPathPair(String key, SimpleSeverletHandler callback) {
this.callback = callback;
}
}
private static ArrayList<SeverletPathPair> severletList = new ArrayList<>();
private static TreeSet<SeverletPathPair> severletList = new TreeSet<>(Comparator.comparingInt((e) -> -e.key.length()));
public static SeverletPathPair addNewSeverlet(String path, SimpleSeverletHandler callback)
{
SeverletPathPair pair = new SeverletPathPair("/webapi/".concat(path), callback);
severletList.add(pair);
severletList.sort(Comparator.comparingInt((a) -> -a.key.length()));
return pair;
}
public static SeverletPathPair addUnsafeSeverlet(String path, SimpleSeverletHandler callback)
{
SeverletPathPair pair = new SeverletPathPair(path, callback);
severletList.add(pair);
severletList.sort(Comparator.comparingInt((a) -> -a.key.length()));
return pair;
}
public static void removeSeverlet(SeverletPathPair pair)