Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[FIXED JENKINS-21969] Performance issue with search box when doing ca…
…se insensitive searching.

(cherry picked from commit 84e8d01)
  • Loading branch information
christ66 authored and olivergondza committed Apr 13, 2014
1 parent 18e5415 commit 592dca5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 4 additions & 1 deletion core/src/main/java/hudson/model/User.java
Expand Up @@ -378,7 +378,10 @@ private static User getOrCreate(String id, String fullName, boolean create) {
Authentication a = Jenkins.getAuthentication();
if(a instanceof AnonymousAuthenticationToken)
return null;
return get(a.getName());

// Since we already know this is a name, we can just call getOrCreate with the name directly.
String id = a.getName();
return getOrCreate(id, id, true);
}

private static volatile long lastScanned;
Expand Down
5 changes: 3 additions & 2 deletions core/src/main/java/hudson/search/CollectionSearchIndex.java
Expand Up @@ -52,13 +52,14 @@ public void find(String token, List<SearchItem> result) {

public void suggest(String token, List<SearchItem> result) {
Collection<SMT> items = all();
if(UserSearchProperty.isCaseInsensitive()){
boolean isCaseSensitive = UserSearchProperty.isCaseInsensitive();
if(isCaseSensitive){
token = token.toLowerCase();
}
if(items==null) return;
for (SMT o : items) {
String name = getName(o);
if(UserSearchProperty.isCaseInsensitive())
if(isCaseSensitive)
name=name.toLowerCase();
if(o!=null && name.contains(token))
result.add(o);
Expand Down

0 comments on commit 592dca5

Please sign in to comment.