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