[FIXED JENKINS-18364] Functions.getRelativeLinkTo is called many times during rendering, so skip checking View.getItems which is expensive.

This commit is contained in:
Jesse Glick committed 2014-04-01 10:53:25 -04:00
1 parent 7037c23d95
commit bcc8614856
3 files changed
+29 -16

No files matched your search

+3 -8
View File
@@ -1014,20 +1014,15 @@ public class Functions {
Item i=p;
String url = "";
Collection<TopLevelItem> viewItems;
if (view != null) {
viewItems = view.getItems();
} else {
viewItems = Collections.emptyList();
}
while(true) {
ItemGroup ig = i.getParent();
url = i.getShortUrl()+url;
if(ig== Jenkins.getInstance() || (view != null && ig == view.getOwnerItemGroup())) {
assert i instanceof TopLevelItem;
if(viewItems.contains((TopLevelItem)i)) {
// if p and the current page belongs to the same view, then return a relative path
if (view != null) {
// assume p and the current page belong to the same view, so return a relative path
// (even if they did not, View.getItem does not by default verify ownership)
return normalizeURI(ancestors.get(view)+'/'+url);
} else {
// otherwise return a path from the root Hudson