Skip to content

Commit

Permalink
Automated g4 rollback of changelist 162220754.
Browse files Browse the repository at this point in the history
*** Reason for rollback ***

app-engine has a buggy implementation of FileInputStream.available() which is throwing IOException

*** Original change description ***

Implement ByteSource.asCharSource(charset).read() using the decoding string constructor instead of streaming the contents into a StringBuilder.

this allows us to avoid a number of copies that are currently happening for each character (1. into a temporary CharBuffer, 2. into a StringBuilder, 3 into the String char[]) and replace it with simply whatever is required by ByteSource.read() and the String(byte[], charset) constructor.  For certain ByteSource implementations (like FileByteSource) Byte...

***

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=162245286
  • Loading branch information
lukesandberg authored and cgdecker committed Jul 24, 2017
1 parent 44b9081 commit b87e1f1
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 298 deletions.

This file was deleted.

12 changes: 0 additions & 12 deletions android/guava/src/com/google/common/io/ByteSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -455,18 +455,6 @@ public Reader openStream() throws IOException {
return new InputStreamReader(ByteSource.this.openStream(), charset);
}

@Override
public String read() throws IOException {
// Reading all the data as a byte array is more efficient than the default read()
// implementation because:
// 1. the string constructor can avoid an extra copy most of the time by correctly sizing the
// internal char array (hard to avoid using StringBuilder)
// 2. we avoid extra copies into temporary buffers altogether
// The downside is that this will cause us to store the file bytes in memory twice for a short
// amount of time.
return new String(ByteSource.this.read(), charset);
}

@Override
public String toString() {
return ByteSource.this.toString() + ".asCharSource(" + charset + ")";
Expand Down

This file was deleted.

12 changes: 0 additions & 12 deletions guava/src/com/google/common/io/ByteSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -455,18 +455,6 @@ public Reader openStream() throws IOException {
return new InputStreamReader(ByteSource.this.openStream(), charset);
}

@Override
public String read() throws IOException {
// Reading all the data as a byte array is more efficient than the default read()
// implementation because:
// 1. the string constructor can avoid an extra copy most of the time by correctly sizing the
// internal char array (hard to avoid using StringBuilder)
// 2. we avoid extra copies into temporary buffers altogether
// The downside is that this will cause us to store the file bytes in memory twice for a short
// amount of time.
return new String(ByteSource.this.read(), charset);
}

@Override
public String toString() {
return ByteSource.this.toString() + ".asCharSource(" + charset + ")";
Expand Down

0 comments on commit b87e1f1

Please sign in to comment.