Remove unnecessary local variables
Change-Id: I20ee3f7258d7e98b9c57b49c21b1e2d1582f626f
This commit is contained in:

committed by
Shawn Pearce

parent
23e1a2e824
commit
bbf93f85cf
@@ -113,8 +113,7 @@ public class DefaultCacheFactory implements MemoryCacheFactory {
|
|||||||
|
|
||||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||||
private static <K, V> CacheBuilder<K, V> newCacheBuilder() {
|
private static <K, V> CacheBuilder<K, V> newCacheBuilder() {
|
||||||
CacheBuilder builder = CacheBuilder.newBuilder();
|
return (CacheBuilder<K, V>) CacheBuilder.newBuilder();
|
||||||
return builder;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <K, V> Weigher<K, V> unitWeight() {
|
private static <K, V> Weigher<K, V> unitWeight() {
|
||||||
|
@@ -55,15 +55,14 @@ public class Permutation {
|
|||||||
*/
|
*/
|
||||||
public void inject(Document dom) {
|
public void inject(Document dom) {
|
||||||
String moduleName = selector.getModuleName();
|
String moduleName = selector.getModuleName();
|
||||||
String moduleFunc = moduleName;
|
|
||||||
|
|
||||||
StringBuilder s = new StringBuilder();
|
StringBuilder s = new StringBuilder();
|
||||||
s.append("\n");
|
s.append("\n");
|
||||||
s.append("function " + moduleFunc + "(){");
|
s.append("function ").append(moduleName).append("(){");
|
||||||
s.append("var s,l,t");
|
s.append("var s,l,t");
|
||||||
s.append(",w=window");
|
s.append(",w=window");
|
||||||
s.append(",d=document");
|
s.append(",d=document");
|
||||||
s.append(",n='" + moduleName + "'");
|
s.append(",n='").append(moduleName).append("'");
|
||||||
s.append(",f=d.createElement('iframe')");
|
s.append(",f=d.createElement('iframe')");
|
||||||
s.append(";");
|
s.append(";");
|
||||||
|
|
||||||
@@ -78,7 +77,7 @@ public class Permutation {
|
|||||||
s.append("i.src=n+'/clear.cache.gif';");
|
s.append("i.src=n+'/clear.cache.gif';");
|
||||||
s.append("b=i.src;");
|
s.append("b=i.src;");
|
||||||
s.append("b=b.substring(0,b.lastIndexOf('/')+1);");
|
s.append("b=b.substring(0,b.lastIndexOf('/')+1);");
|
||||||
s.append(moduleFunc + "=null;"); // allow us to GC
|
s.append(moduleName).append("=null;"); // allow us to GC
|
||||||
s.append("f.contentWindow.gwtOnLoad(undefined,n,b);");
|
s.append("f.contentWindow.gwtOnLoad(undefined,n,b);");
|
||||||
s.append("}");
|
s.append("}");
|
||||||
s.append("}");
|
s.append("}");
|
||||||
@@ -87,14 +86,14 @@ public class Permutation {
|
|||||||
// exact name here is known to the IFrameLinker and is called by
|
// exact name here is known to the IFrameLinker and is called by
|
||||||
// the code in the iframe.
|
// the code in the iframe.
|
||||||
//
|
//
|
||||||
s.append(moduleFunc + ".onScriptLoad=function(){");
|
s.append(moduleName).append(".onScriptLoad=function(){");
|
||||||
s.append("s=1;m();");
|
s.append("s=1;m();");
|
||||||
s.append("};");
|
s.append("};");
|
||||||
|
|
||||||
// Set l true when the browser has finished processing the iframe
|
// Set l true when the browser has finished processing the iframe
|
||||||
// tag, and everything else on the page.
|
// tag, and everything else on the page.
|
||||||
//
|
//
|
||||||
s.append(moduleFunc + ".r=function(){");
|
s.append(moduleName).append(".r=function(){");
|
||||||
s.append("l=1;m();");
|
s.append("l=1;m();");
|
||||||
s.append("};");
|
s.append("};");
|
||||||
|
|
||||||
@@ -110,14 +109,13 @@ public class Permutation {
|
|||||||
// refresh quirks in Safari. We have to use the location.replace trick to
|
// refresh quirks in Safari. We have to use the location.replace trick to
|
||||||
// avoid FF2 refresh quirks.
|
// avoid FF2 refresh quirks.
|
||||||
//
|
//
|
||||||
s.append("f.contentWindow.location.replace(n+'/" + cacheHTML + "');");
|
s.append("f.contentWindow.location.replace(n+'/").append(cacheHTML).append("');");
|
||||||
|
|
||||||
// defer attribute here is to workaround IE running immediately.
|
// defer attribute here is to workaround IE running immediately.
|
||||||
//
|
//
|
||||||
s.append("d.write('<script defer=\"defer\">" //
|
s.append("d.write('<script defer=\"defer\">").append(moduleName).append(".r()</'+'script>');");
|
||||||
+ moduleFunc + ".r()</'+'script>');");
|
|
||||||
s.append("}");
|
s.append("}");
|
||||||
s.append(moduleFunc + "();");
|
s.append(moduleName).append("();");
|
||||||
s.append("\n//");
|
s.append("\n//");
|
||||||
|
|
||||||
final Element html = dom.getDocumentElement();
|
final Element html = dom.getDocumentElement();
|
||||||
|
@@ -68,13 +68,12 @@ public class LinkFindReplace implements FindReplace {
|
|||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"Invalid scheme (" + toString() + "): " + href);
|
"Invalid scheme (" + toString() + "): " + href);
|
||||||
}
|
}
|
||||||
String result = new SafeHtmlBuilder()
|
return new SafeHtmlBuilder()
|
||||||
.openAnchor()
|
.openAnchor()
|
||||||
.setAttribute("href", href)
|
.setAttribute("href", href)
|
||||||
.append(SafeHtml.asis(input))
|
.append(SafeHtml.asis(input))
|
||||||
.closeAnchor()
|
.closeAnchor()
|
||||||
.asString();
|
.asString();
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -133,12 +133,10 @@ public class RelativeDateFormatter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static long upperLimit(long unit) {
|
private static long upperLimit(long unit) {
|
||||||
long limit = unit + unit / 2;
|
return unit + unit / 2;
|
||||||
return limit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static long round(long n, long unit) {
|
private static long round(long n, long unit) {
|
||||||
long rounded = (n + unit / 2) / unit;
|
return (n + unit / 2) / unit;
|
||||||
return rounded;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -219,11 +219,8 @@ public class PatchTable extends Composite {
|
|||||||
if (previousPatchIndex < 0) {
|
if (previousPatchIndex < 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
InlineHyperlink link =
|
return createLink(previousPatchIndex, patchType,
|
||||||
createLink(previousPatchIndex, patchType,
|
SafeHtml.asis(Util.C.prevPatchLinkIcon()), null);
|
||||||
SafeHtml.asis(Util.C.prevPatchLinkIcon()), null);
|
|
||||||
|
|
||||||
return link;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -234,11 +231,8 @@ public class PatchTable extends Composite {
|
|||||||
if (nextPatchIndex < 0) {
|
if (nextPatchIndex < 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
InlineHyperlink link =
|
return createLink(nextPatchIndex, patchType, null,
|
||||||
createLink(nextPatchIndex, patchType, null,
|
SafeHtml.asis(Util.C.nextPatchLinkIcon()));
|
||||||
SafeHtml.asis(Util.C.nextPatchLinkIcon()));
|
|
||||||
|
|
||||||
return link;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -267,7 +267,6 @@ public class HtmlDomUtil {
|
|||||||
factory.setExpandEntityReferences(false);
|
factory.setExpandEntityReferences(false);
|
||||||
factory.setIgnoringComments(true);
|
factory.setIgnoringComments(true);
|
||||||
factory.setCoalescing(true);
|
factory.setCoalescing(true);
|
||||||
final DocumentBuilder parser = factory.newDocumentBuilder();
|
return factory.newDocumentBuilder();
|
||||||
return parser;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -92,7 +92,7 @@ public class Publish implements RestModifyView<RevisionResource, Input>,
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Change updateDraftChange(RevisionResource rsrc) throws OrmException {
|
private Change updateDraftChange(RevisionResource rsrc) throws OrmException {
|
||||||
Change updatedChange = dbProvider.get().changes()
|
return dbProvider.get().changes()
|
||||||
.atomicUpdate(rsrc.getChange().getId(),
|
.atomicUpdate(rsrc.getChange().getId(),
|
||||||
new AtomicUpdate<Change>() {
|
new AtomicUpdate<Change>() {
|
||||||
@Override
|
@Override
|
||||||
@@ -104,11 +104,10 @@ public class Publish implements RestModifyView<RevisionResource, Input>,
|
|||||||
return change;
|
return change;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return updatedChange;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private PatchSet updateDraftPatchSet(RevisionResource rsrc) throws OrmException {
|
private PatchSet updateDraftPatchSet(RevisionResource rsrc) throws OrmException {
|
||||||
final PatchSet updatedPatchSet = dbProvider.get().patchSets()
|
return dbProvider.get().patchSets()
|
||||||
.atomicUpdate(rsrc.getPatchSet().getId(),
|
.atomicUpdate(rsrc.getPatchSet().getId(),
|
||||||
new AtomicUpdate<PatchSet>() {
|
new AtomicUpdate<PatchSet>() {
|
||||||
@Override
|
@Override
|
||||||
@@ -117,7 +116,6 @@ public class Publish implements RestModifyView<RevisionResource, Input>,
|
|||||||
return patchset;
|
return patchset;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return updatedPatchSet;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -163,7 +163,7 @@ public class Submit implements RestModifyView<RevisionResource, SubmitInput>,
|
|||||||
*/
|
*/
|
||||||
public ChangeMessage getConflictMessage(RevisionResource rsrc)
|
public ChangeMessage getConflictMessage(RevisionResource rsrc)
|
||||||
throws OrmException {
|
throws OrmException {
|
||||||
ChangeMessage msg = Iterables.getFirst(Iterables.filter(
|
return Iterables.getFirst(Iterables.filter(
|
||||||
Lists.reverse(dbProvider.get().changeMessages()
|
Lists.reverse(dbProvider.get().changeMessages()
|
||||||
.byChange(rsrc.getChange().getId())
|
.byChange(rsrc.getChange().getId())
|
||||||
.toList()),
|
.toList()),
|
||||||
@@ -173,7 +173,6 @@ public class Submit implements RestModifyView<RevisionResource, SubmitInput>,
|
|||||||
return input.getAuthor() == null;
|
return input.getAuthor() == null;
|
||||||
}
|
}
|
||||||
}), null);
|
}), null);
|
||||||
return msg;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Change submit(RevisionResource rsrc, IdentifiedUser caller)
|
public Change submit(RevisionResource rsrc, IdentifiedUser caller)
|
||||||
|
@@ -233,6 +233,7 @@ public class QueryProcessor {
|
|||||||
* there are more than {@code limit} matches and suggest to its own caller
|
* there are more than {@code limit} matches and suggest to its own caller
|
||||||
* that the query could be retried with {@link #setSortkeyBefore(String)}.
|
* that the query could be retried with {@link #setSortkeyBefore(String)}.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public List<List<ChangeData>> queryChanges(List<String> queries)
|
public List<List<ChangeData>> queryChanges(List<String> queries)
|
||||||
throws OrmException, QueryParseException {
|
throws OrmException, QueryParseException {
|
||||||
final Predicate<ChangeData> visibleToMe = queryBuilder.is_visible();
|
final Predicate<ChangeData> visibleToMe = queryBuilder.is_visible();
|
||||||
@@ -241,13 +242,11 @@ public class QueryProcessor {
|
|||||||
// Parse and rewrite all queries.
|
// Parse and rewrite all queries.
|
||||||
List<Integer> limits = Lists.newArrayListWithCapacity(cnt);
|
List<Integer> limits = Lists.newArrayListWithCapacity(cnt);
|
||||||
List<ChangeDataSource> sources = Lists.newArrayListWithCapacity(cnt);
|
List<ChangeDataSource> sources = Lists.newArrayListWithCapacity(cnt);
|
||||||
for (int i = 0; i < cnt; i++) {
|
for (String query : queries) {
|
||||||
Predicate<ChangeData> q = parseQuery(queries.get(i), visibleToMe);
|
Predicate<ChangeData> q = parseQuery(query, visibleToMe);
|
||||||
Predicate<ChangeData> s = queryRewriter.rewrite(q);
|
Predicate<ChangeData> s = queryRewriter.rewrite(q);
|
||||||
if (!(s instanceof ChangeDataSource)) {
|
if (!(s instanceof ChangeDataSource)) {
|
||||||
@SuppressWarnings("unchecked")
|
q = Predicate.and(queryBuilder.status_open(), q);
|
||||||
Predicate<ChangeData> o = Predicate.and(queryBuilder.status_open(), q);
|
|
||||||
q = o;
|
|
||||||
s = queryRewriter.rewrite(q);
|
s = queryRewriter.rewrite(q);
|
||||||
}
|
}
|
||||||
if (!(s instanceof ChangeDataSource)) {
|
if (!(s instanceof ChangeDataSource)) {
|
||||||
|
@@ -299,9 +299,7 @@ public class FromAddressGeneratorProviderTest {
|
|||||||
final Account account = new Account(userId, TimeUtil.nowTs());
|
final Account account = new Account(userId, TimeUtil.nowTs());
|
||||||
account.setFullName(name);
|
account.setFullName(name);
|
||||||
account.setPreferredEmail(email);
|
account.setPreferredEmail(email);
|
||||||
final AccountState s =
|
return new AccountState(account, Collections.<AccountGroup.UUID> emptySet(),
|
||||||
new AccountState(account, Collections.<AccountGroup.UUID> emptySet(),
|
Collections.<AccountExternalId> emptySet());
|
||||||
Collections.<AccountExternalId> emptySet());
|
|
||||||
return s;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -57,8 +57,7 @@ public class InMemoryDatabase implements SchemaFactory<ReviewDb> {
|
|||||||
final Properties p = new Properties();
|
final Properties p = new Properties();
|
||||||
p.setProperty("driver", org.h2.Driver.class.getName());
|
p.setProperty("driver", org.h2.Driver.class.getName());
|
||||||
p.setProperty("url", "jdbc:h2:mem:" + "Test_" + (++dbCnt));
|
p.setProperty("url", "jdbc:h2:mem:" + "Test_" + (++dbCnt));
|
||||||
final DataSource dataSource = new SimpleDataSource(p);
|
return new SimpleDataSource(p);
|
||||||
return dataSource;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Drop the database from memory; does nothing if the instance was null. */
|
/** Drop the database from memory; does nothing if the instance was null. */
|
||||||
|
@@ -73,9 +73,8 @@ public class OptionHandlers {
|
|||||||
return (Class<?>) p.getActualTypeArguments()[0];
|
return (Class<?>) p.getActualTypeArguments()[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
private static Binding<OptionHandlerFactory<?>> cast(Binding<?> e) {
|
private static Binding<OptionHandlerFactory<?>> cast(Binding<?> e) {
|
||||||
@SuppressWarnings("unchecked")
|
return (Binding<OptionHandlerFactory<?>>) e;
|
||||||
Binding<OptionHandlerFactory<?>> b = (Binding<OptionHandlerFactory<?>>) e;
|
|
||||||
return b;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user