Skip to content
This repository has been archived by the owner on Jul 21, 2023. It is now read-only.

Commit

Permalink
Style tweaks to match Square.
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeWharton committed Apr 14, 2013
1 parent 3d8cd03 commit 1a2bd20
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 20 deletions.
24 changes: 11 additions & 13 deletions src/main/java/com/jakewharton/disklrucache/DiskLruCache.java
Expand Up @@ -64,12 +64,12 @@
* entry may have only one editor at one time; if a value is not available to be
* edited then {@link #edit} will return null.
* <ul>
* <li>When an entry is being <strong>created</strong> it is necessary to
* supply a full set of values; the empty value should be used as a
* placeholder if necessary.
* <li>When an entry is being <strong>edited</strong>, it is not necessary
* to supply data for every value; values default to their previous
* value.
* <li>When an entry is being <strong>created</strong> it is necessary to
* supply a full set of values; the empty value should be used as a
* placeholder if necessary.
* <li>When an entry is being <strong>edited</strong>, it is not necessary
* to supply data for every value; values default to their previous
* value.
* </ul>
* Every {@link #edit} call must be matched by a call to {@link Editor#commit}
* or {@link Editor#abort}. Committing is atomic: a read observes the full set
Expand Down Expand Up @@ -147,8 +147,8 @@ public final class DiskLruCache implements Closeable {
private final int valueCount;
private long size = 0;
private Writer journalWriter;
private final LinkedHashMap<String, Entry> lruEntries
= new LinkedHashMap<String, Entry>(0, 0.75f, true);
private final LinkedHashMap<String, Entry> lruEntries =
new LinkedHashMap<String, Entry>(0, 0.75f, true);
private int redundantOpCount;

/**
Expand Down Expand Up @@ -224,8 +224,7 @@ public static DiskLruCache open(File directory, int appVersion, int valueCount,
cache.readJournal();
cache.processJournal();
cache.journalWriter = new BufferedWriter(
new OutputStreamWriter(new FileOutputStream(cache.journalFile, true),
Util.US_ASCII));
new OutputStreamWriter(new FileOutputStream(cache.journalFile, true), Util.US_ASCII));
return cache;
} catch (IOException journalIsCorrupt) {
System.out
Expand All @@ -246,8 +245,7 @@ public static DiskLruCache open(File directory, int appVersion, int valueCount,
}

private void readJournal() throws IOException {
StrictLineReader reader
= new StrictLineReader(new FileInputStream(journalFile), Util.US_ASCII);
StrictLineReader reader = new StrictLineReader(new FileInputStream(journalFile), Util.US_ASCII);
try {
String magic = reader.readLine();
String version = reader.readLine();
Expand Down Expand Up @@ -568,7 +566,7 @@ private synchronized void completeEdit(Editor editor, boolean success) throws IO
*/
private boolean journalRebuildRequired() {
final int redundantOpCompactThreshold = 2000;
return redundantOpCount >= redundantOpCompactThreshold
return redundantOpCount >= redundantOpCompactThreshold //
&& redundantOpCount >= lruEntries.size();
}

Expand Down
14 changes: 7 additions & 7 deletions src/main/java/com/jakewharton/disklrucache/StrictLineReader.java
Expand Up @@ -27,10 +27,10 @@
/**
* Buffers input from an {@link InputStream} for reading lines.
*
* <p>This class is used for buffered reading of lines. For purposes of this class, a line ends with
* "\n" or "\r\n". End of input is reported by throwing {@code EOFException}. Unterminated line at
* end of input is invalid and will be ignored, the caller may use {@code hasUnterminatedLine()}
* to detect it after catching the {@code EOFException}.
* <p>This class is used for buffered reading of lines. For purposes of this class, a line ends
* with "\n" or "\r\n". End of input is reported by throwing {@code EOFException}. Unterminated
* line at end of input is invalid and will be ignored, the caller may use {@code
* hasUnterminatedLine()} to detect it after catching the {@code EOFException}.
*
* <p>This class is intended for reading input that strictly consists of lines, such as line-based
* cache entries or cache journal. Unlike the {@link java.io.BufferedReader} which in conjunction
Expand Down Expand Up @@ -64,7 +64,7 @@ class StrictLineReader implements Closeable {
*
* @param in the {@code InputStream} to read data from.
* @param charset the charset used to decode data. Only US-ASCII, UTF-8 and ISO-8859-1 are
* supported.
* supported.
* @throws NullPointerException if {@code in} or {@code charset} is null.
* @throws IllegalArgumentException if the specified charset is not supported.
*/
Expand All @@ -78,10 +78,10 @@ public StrictLineReader(InputStream in, Charset charset) {
* @param in the {@code InputStream} to read data from.
* @param capacity the capacity of the buffer.
* @param charset the charset used to decode data. Only US-ASCII, UTF-8 and ISO-8859-1 are
* supported.
* supported.
* @throws NullPointerException if {@code in} or {@code charset} is null.
* @throws IllegalArgumentException if {@code capacity} is negative or zero
* or the specified charset is not supported.
* or the specified charset is not supported.
*/
public StrictLineReader(InputStream in, int capacity, Charset charset) {
if (in == null || charset == null) {
Expand Down

0 comments on commit 1a2bd20

Please sign in to comment.