Skip to content

Commit

Permalink
Down integrate to GitHub
Browse files Browse the repository at this point in the history
  • Loading branch information
Hao Nguyen committed Jun 26, 2019
1 parent 7e276a3 commit 51026d9
Show file tree
Hide file tree
Showing 97 changed files with 5,190 additions and 7,080 deletions.
2 changes: 1 addition & 1 deletion cmake/tests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ endforeach(proto_file)

set(common_test_files
${protobuf_source_dir}/src/google/protobuf/arena_test_util.cc
${protobuf_source_dir}/src/google/protobuf/map_test_util.cc
${protobuf_source_dir}/src/google/protobuf/map_test_util.inc
${protobuf_source_dir}/src/google/protobuf/test_util.cc
${protobuf_source_dir}/src/google/protobuf/test_util.inc
${protobuf_source_dir}/src/google/protobuf/testing/file.cc
Expand Down
14 changes: 6 additions & 8 deletions conformance/binary_json_conformance_suite.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1978,14 +1978,12 @@ void BinaryAndJsonConformanceSuite::RunSuiteImpl() {
})",
"repeated_timestamp: {seconds: -62135596800}"
"repeated_timestamp: {seconds: 253402300799 nanos: 999999999}");
RunValidJsonTest(
"TimestampWithPositiveOffset", REQUIRED,
R"({"optionalTimestamp": "1970-01-01T08:00:01+08:00"})",
"optional_timestamp: {seconds: 1}");
RunValidJsonTest(
"TimestampWithNegativeOffset", REQUIRED,
R"({"optionalTimestamp": "1969-12-31T16:00:01-08:00"})",
"optional_timestamp: {seconds: 1}");
RunValidJsonTest("TimestampWithPositiveOffset", REQUIRED,
R"({"optionalTimestamp": "1970-01-01T08:00:01+08:00"})",
"optional_timestamp: {seconds: 1}");
RunValidJsonTest("TimestampWithNegativeOffset", REQUIRED,
R"({"optionalTimestamp": "1969-12-31T16:00:01-08:00"})",
"optional_timestamp: {seconds: 1}");
RunValidJsonTest(
"TimestampNull", REQUIRED,
R"({"optionalTimestamp": null})",
Expand Down
19 changes: 17 additions & 2 deletions java/core/src/main/java/com/google/protobuf/BooleanArrayList.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ final class BooleanArrayList extends AbstractProtobufList<Boolean>
implements BooleanList, RandomAccess, PrimitiveNonBoxingCollection {

private static final BooleanArrayList EMPTY_LIST = new BooleanArrayList(new boolean[0], 0);

static {
EMPTY_LIST.makeImmutable();
}
Expand Down Expand Up @@ -160,6 +159,12 @@ public boolean setBoolean(int index, boolean element) {
return previousValue;
}

@Override
public boolean add(Boolean element) {
addBoolean(element);
return true;
}

@Override
public void add(int index, Boolean element) {
addBoolean(index, element);
Expand All @@ -168,7 +173,17 @@ public void add(int index, Boolean element) {
/** Like {@link #add(Boolean)} but more efficient in that it doesn't box the element. */
@Override
public void addBoolean(boolean element) {
addBoolean(size, element);
ensureIsMutable();
if (size == array.length) {
// Resize to 1.5x the size
int length = ((size * 3) / 2) + 1;
boolean[] newArray = new boolean[length];

System.arraycopy(array, 0, newArray, 0, size);
array = newArray;
}

array[size++] = element;
}

/** Like {@link #add(int, Boolean)} but more efficient in that it doesn't box the element. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,9 @@ final boolean shouldDiscardUnknownFields() {
/**
* Returns true if the stream has reached the end of the input. This is the case if either the end
* of the underlying input source has been reached or if the stream has reached a limit created
* using {@link #pushLimit(int)}.
* using {@link #pushLimit(int)}. This function may get blocked when using StreamDecoder as it
* invokes {@link #StreamDecoder.tryRefillBuffer(int)} in this function which will try to read
* bytes from input.
*/
public abstract boolean isAtEnd() throws IOException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
public final class DiscardUnknownFieldsParser {

/**
* Warps a given {@link Parser} into a new {@link Parser} that discards unknown fields during
* Wraps a given {@link Parser} into a new {@link Parser} that discards unknown fields during
* parsing.
*
* <p>Usage example:
Expand Down
19 changes: 17 additions & 2 deletions java/core/src/main/java/com/google/protobuf/DoubleArrayList.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ final class DoubleArrayList extends AbstractProtobufList<Double>
implements DoubleList, RandomAccess, PrimitiveNonBoxingCollection {

private static final DoubleArrayList EMPTY_LIST = new DoubleArrayList(new double[0], 0);

static {
EMPTY_LIST.makeImmutable();
}
Expand Down Expand Up @@ -160,6 +159,12 @@ public double setDouble(int index, double element) {
return previousValue;
}

@Override
public boolean add(Double element) {
addDouble(element);
return true;
}

@Override
public void add(int index, Double element) {
addDouble(index, element);
Expand All @@ -168,7 +173,17 @@ public void add(int index, Double element) {
/** Like {@link #add(Double)} but more efficient in that it doesn't box the element. */
@Override
public void addDouble(double element) {
addDouble(size, element);
ensureIsMutable();
if (size == array.length) {
// Resize to 1.5x the size
int length = ((size * 3) / 2) + 1;
double[] newArray = new double[length];

System.arraycopy(array, 0, newArray, 0, size);
array = newArray;
}

array[size++] = element;
}

/** Like {@link #add(int, Double)} but more efficient in that it doesn't box the element. */
Expand Down
19 changes: 17 additions & 2 deletions java/core/src/main/java/com/google/protobuf/FloatArrayList.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ final class FloatArrayList extends AbstractProtobufList<Float>
implements FloatList, RandomAccess, PrimitiveNonBoxingCollection {

private static final FloatArrayList EMPTY_LIST = new FloatArrayList(new float[0], 0);

static {
EMPTY_LIST.makeImmutable();
}
Expand Down Expand Up @@ -159,6 +158,12 @@ public float setFloat(int index, float element) {
return previousValue;
}

@Override
public boolean add(Float element) {
addFloat(element);
return true;
}

@Override
public void add(int index, Float element) {
addFloat(index, element);
Expand All @@ -167,7 +172,17 @@ public void add(int index, Float element) {
/** Like {@link #add(Float)} but more efficient in that it doesn't box the element. */
@Override
public void addFloat(float element) {
addFloat(size, element);
ensureIsMutable();
if (size == array.length) {
// Resize to 1.5x the size
int length = ((size * 3) / 2) + 1;
float[] newArray = new float[length];

System.arraycopy(array, 0, newArray, 0, size);
array = newArray;
}

array[size++] = element;
}

/** Like {@link #add(int, Float)} but more efficient in that it doesn't box the element. */
Expand Down
Loading

0 comments on commit 51026d9

Please sign in to comment.