Split GWT download of SideBySide1 from SideBySide2
Most users use CS2/SBS2 and do not need the SBS1 code. Split SB1 from SBS2, shaving about 160 KiB off of an optimized download. There may be value in splitting CS1 out from the main download, but this has not been evaluated. Splitting is not always obvious as classes that are not in the main download and are used across splits get pushed into a "remainder" download. It is worthwhile to keep that remainder as small as possible. Change-Id: I5abc21ebe1fcb2b3663cd501f77fe8d062894bd0
This commit is contained in:
@@ -672,85 +672,95 @@ public class Dispatcher {
|
|||||||
patchSetDetail, patchTable, topView, null);
|
patchSetDetail, patchTable, topView, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void patch(String token, final PatchSet.Id baseId, final Patch.Key id,
|
public static void patch(String token, PatchSet.Id baseId,
|
||||||
final DisplaySide side, final int line,
|
Patch.Key id, DisplaySide side, int line,
|
||||||
final int patchIndex, final PatchSetDetail patchSetDetail,
|
int patchIndex, PatchSetDetail patchSetDetail,
|
||||||
final PatchTable patchTable, final PatchScreen.TopView topView,
|
PatchTable patchTable, PatchScreen.TopView topView,
|
||||||
final String panelType) {
|
String panelType) {
|
||||||
final PatchScreen.TopView top = topView == null ?
|
if (id == null) {
|
||||||
Gerrit.getPatchScreenTopView() : topView;
|
Gerrit.display(token, new NotFoundScreen());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String panel = panelType;
|
||||||
|
if (panel == null) {
|
||||||
|
int c = token.lastIndexOf(',');
|
||||||
|
panel = 0 <= c ? token.substring(c + 1) : "";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ("".equals(panel)) {
|
||||||
|
if (isChangeScreen2()) {
|
||||||
|
if (Gerrit.isSignedIn()
|
||||||
|
&& DiffView.UNIFIED_DIFF.equals(Gerrit.getUserAccount()
|
||||||
|
.getGeneralPreferences().getDiffView())) {
|
||||||
|
sbs1(token, baseId, id, patchIndex, patchSetDetail, patchTable,
|
||||||
|
topView, PatchScreen.Type.UNIFIED);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sbs2(token, baseId, id, side, line, false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sbs1(token, baseId, id, patchIndex, patchSetDetail, patchTable, topView,
|
||||||
|
PatchScreen.Type.SIDE_BY_SIDE);
|
||||||
|
return;
|
||||||
|
} else if ("unified".equals(panel)) {
|
||||||
|
sbs1(token, baseId, id, patchIndex, patchSetDetail, patchTable, topView,
|
||||||
|
PatchScreen.Type.UNIFIED);
|
||||||
|
return;
|
||||||
|
} else if ("cm".equals(panel) && Gerrit.getConfig().getNewFeatures()) {
|
||||||
|
if (Gerrit.isSignedIn()
|
||||||
|
&& DiffView.UNIFIED_DIFF.equals(Gerrit.getUserAccount()
|
||||||
|
.getGeneralPreferences().getDiffView())) {
|
||||||
|
sbs1(token, baseId, id, patchIndex, patchSetDetail, patchTable,
|
||||||
|
topView, PatchScreen.Type.UNIFIED);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sbs2(token, baseId, id, side, line, false);
|
||||||
|
return;
|
||||||
|
} else if ("".equals(panel) || "sidebyside".equals(panel)) {
|
||||||
|
sbs1(token, baseId, id, patchIndex, patchSetDetail, patchTable, topView,
|
||||||
|
PatchScreen.Type.SIDE_BY_SIDE);
|
||||||
|
return;
|
||||||
|
} else if (panel.equals("edit")) {
|
||||||
|
sbs2(token, null, id, null, 0, true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Gerrit.display(token, new NotFoundScreen());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void sbs1(final String token, final PatchSet.Id baseId,
|
||||||
|
final Patch.Key id, final int patchIndex,
|
||||||
|
final PatchSetDetail patchSetDetail, final PatchTable patchTable,
|
||||||
|
final PatchScreen.TopView topView, final PatchScreen.Type type) {
|
||||||
GWT.runAsync(new AsyncSplit(token) {
|
GWT.runAsync(new AsyncSplit(token) {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess() {
|
public void onSuccess() {
|
||||||
Gerrit.display(token, select());
|
PatchScreen.TopView top = topView == null
|
||||||
}
|
? Gerrit.getPatchScreenTopView()
|
||||||
|
: topView;
|
||||||
private Screen select() {
|
switch (type) {
|
||||||
if (id != null) {
|
case SIDE_BY_SIDE:
|
||||||
String panel = panelType;
|
Gerrit.display(token, new PatchScreen.SideBySide(id, patchIndex,
|
||||||
if (panel == null) {
|
patchSetDetail, patchTable, top, baseId));
|
||||||
int c = token.lastIndexOf(',');
|
break;
|
||||||
panel = 0 <= c ? token.substring(c + 1) : "";
|
case UNIFIED:
|
||||||
}
|
Gerrit.display(token, new PatchScreen.Unified(id, patchIndex,
|
||||||
|
patchSetDetail, patchTable, top, baseId));
|
||||||
if ("".equals(panel)) {
|
break;
|
||||||
if (isChangeScreen2()) {
|
|
||||||
if (Gerrit.isSignedIn()
|
|
||||||
&& DiffView.UNIFIED_DIFF.equals(Gerrit.getUserAccount()
|
|
||||||
.getGeneralPreferences().getDiffView())) {
|
|
||||||
return new PatchScreen.Unified(id, patchIndex, patchSetDetail,
|
|
||||||
patchTable, top, baseId);
|
|
||||||
}
|
|
||||||
return new SideBySide2(baseId, id.getParentKey(), id.get(),
|
|
||||||
side, line);
|
|
||||||
}
|
|
||||||
return new PatchScreen.SideBySide( //
|
|
||||||
id, //
|
|
||||||
patchIndex, //
|
|
||||||
patchSetDetail, //
|
|
||||||
patchTable, //
|
|
||||||
top, //
|
|
||||||
baseId //
|
|
||||||
);
|
|
||||||
} else if ("unified".equals(panel)) {
|
|
||||||
return new PatchScreen.Unified( //
|
|
||||||
id, //
|
|
||||||
patchIndex, //
|
|
||||||
patchSetDetail, //
|
|
||||||
patchTable, //
|
|
||||||
top, //
|
|
||||||
baseId //
|
|
||||||
);
|
|
||||||
} else if ("cm".equals(panel) && Gerrit.getConfig().getNewFeatures()) {
|
|
||||||
if (Gerrit.isSignedIn()
|
|
||||||
&& DiffView.UNIFIED_DIFF.equals(Gerrit.getUserAccount()
|
|
||||||
.getGeneralPreferences().getDiffView())) {
|
|
||||||
return new PatchScreen.Unified( //
|
|
||||||
id, //
|
|
||||||
patchIndex, //
|
|
||||||
patchSetDetail, //
|
|
||||||
patchTable, //
|
|
||||||
top, //
|
|
||||||
baseId //
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return new SideBySide2(baseId, id.getParentKey(), id.get(),
|
|
||||||
side, line);
|
|
||||||
} else if ("".equals(panel) || "sidebyside".equals(panel)) {
|
|
||||||
return new PatchScreen.SideBySide(//
|
|
||||||
id, //
|
|
||||||
patchIndex,//
|
|
||||||
patchSetDetail,//
|
|
||||||
patchTable,//
|
|
||||||
top,//
|
|
||||||
baseId);//
|
|
||||||
} else if (panel.equals("edit")) {
|
|
||||||
return new EditScreen(id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return new NotFoundScreen();
|
private static void sbs2(final String token, final PatchSet.Id baseId,
|
||||||
|
final Patch.Key id, final DisplaySide side, final int line,
|
||||||
|
final boolean edit) {
|
||||||
|
GWT.runAsync(new AsyncSplit(token) {
|
||||||
|
@Override
|
||||||
|
public void onSuccess() {
|
||||||
|
Gerrit.display(token, edit
|
||||||
|
? new EditScreen(id)
|
||||||
|
: new SideBySide2(baseId, id.getParentKey(), id.get(), side, line));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user