Skip to content

Commit

Permalink
Improve operation time when getting a list of types (#539)
Browse files Browse the repository at this point in the history
TreeSet is much faster since it doesn't have to hash the CClassType. It might even be faster than ArrayList in this case.
  • Loading branch information
PseudoKnight authored and LadyCailin committed Aug 22, 2019
1 parent 522b5b4 commit c20276f
Showing 1 changed file with 2 additions and 1 deletion.
Expand Up @@ -17,6 +17,7 @@
import com.laytonsmith.core.objects.ObjectDefinitionTable;
import com.laytonsmith.core.objects.UserObject;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
Expand Down Expand Up @@ -455,7 +456,7 @@ public CClassType[] getInterfacesForType(Environment env) {
* @return
*/
protected Set<CClassType> getTypes() {
Set<CClassType> t = new HashSet<>();
Set<CClassType> t = new TreeSet<>(Comparator.comparing(CClassType::getFQCN));
for(FullyQualifiedClassName type : types) {
try {
t.add(CClassType.get(type));
Expand Down

0 comments on commit c20276f

Please sign in to comment.