Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(199)

Side by Side Diff: third_party/protobuf/java/core/src/main/java/com/google/protobuf/UnknownFieldSetLite.java

Issue 2590803003: Revert "third_party/protobuf: Update to HEAD (83d681ee2c)" (Closed)
Patch Set: Created 3 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Protocol Buffers - Google's data interchange format 1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2008 Google Inc. All rights reserved. 2 // Copyright 2008 Google Inc. All rights reserved.
3 // https://developers.google.com/protocol-buffers/ 3 // https://developers.google.com/protocol-buffers/
4 // 4 //
5 // Redistribution and use in source and binary forms, with or without 5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are 6 // modification, are permitted provided that the following conditions are
7 // met: 7 // met:
8 // 8 //
9 // * Redistributions of source code must retain the above copyright 9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer. 10 // notice, this list of conditions and the following disclaimer.
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 ((UnknownFieldSetLite) objects[i]).writeTo(output); 169 ((UnknownFieldSetLite) objects[i]).writeTo(output);
170 output.writeTag(fieldNumber, WireFormat.WIRETYPE_END_GROUP); 170 output.writeTag(fieldNumber, WireFormat.WIRETYPE_END_GROUP);
171 break; 171 break;
172 default: 172 default:
173 throw InvalidProtocolBufferException.invalidWireType(); 173 throw InvalidProtocolBufferException.invalidWireType();
174 } 174 }
175 } 175 }
176 } 176 }
177 177
178 /** 178 /**
179 * Serializes the set and writes it to {@code output} using {@code MessageSet} wire format.
180 *
181 * <p>For use by generated code only.
182 */
183 public void writeAsMessageSetTo(CodedOutputStream output) throws IOException {
184 for (int i = 0; i < count; i++) {
185 int fieldNumber = WireFormat.getTagFieldNumber(tags[i]);
186 output.writeRawMessageSetExtension(fieldNumber, (ByteString) objects[i]);
187 }
188 }
189
190 /**
191 * Get the number of bytes required to encode this field, including field
192 * number, using {@code MessageSet} wire format.
193 */
194 public int getSerializedSizeAsMessageSet() {
195 int size = memoizedSerializedSize;
196 if (size != -1) {
197 return size;
198 }
199
200 size = 0;
201 for (int i = 0; i < count; i++) {
202 int tag = tags[i];
203 int fieldNumber = WireFormat.getTagFieldNumber(tag);
204 size += CodedOutputStream.computeRawMessageSetExtensionSize(
205 fieldNumber, (ByteString) objects[i]);
206 }
207
208 memoizedSerializedSize = size;
209
210 return size;
211 }
212
213 /**
214 * Get the number of bytes required to encode this set. 179 * Get the number of bytes required to encode this set.
215 * 180 *
216 * <p>For use by generated code only. 181 * <p>For use by generated code only.
217 */ 182 */
218 public int getSerializedSize() { 183 public int getSerializedSize() {
219 int size = memoizedSerializedSize; 184 int size = memoizedSerializedSize;
220 if (size != -1) { 185 if (size != -1) {
221 return size; 186 return size;
222 } 187 }
223 188
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 * @param buffer the buffer to write to 261 * @param buffer the buffer to write to
297 * @param indent the number of spaces the fields should be indented by 262 * @param indent the number of spaces the fields should be indented by
298 */ 263 */
299 final void printWithIndent(StringBuilder buffer, int indent) { 264 final void printWithIndent(StringBuilder buffer, int indent) {
300 for (int i = 0; i < count; i++) { 265 for (int i = 0; i < count; i++) {
301 int fieldNumber = WireFormat.getTagFieldNumber(tags[i]); 266 int fieldNumber = WireFormat.getTagFieldNumber(tags[i]);
302 MessageLiteToString.printField(buffer, indent, String.valueOf(fieldNumber) , objects[i]); 267 MessageLiteToString.printField(buffer, indent, String.valueOf(fieldNumber) , objects[i]);
303 } 268 }
304 } 269 }
305 270
306 // Package private for unsafe experimental runtime. 271 private void storeField(int tag, Object value) {
307 void storeField(int tag, Object value) {
308 ensureCapacity(); 272 ensureCapacity();
309 273
310 tags[count] = tag; 274 tags[count] = tag;
311 objects[count] = value; 275 objects[count] = value;
312 count++; 276 count++;
313 } 277 }
314 278
315 /** 279 /**
316 * Ensures that our arrays are long enough to store more metadata. 280 * Ensures that our arrays are long enough to store more metadata.
317 */ 281 */
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 // Ensures initialization in mergeFieldFrom. 369 // Ensures initialization in mergeFieldFrom.
406 while (true) { 370 while (true) {
407 final int tag = input.readTag(); 371 final int tag = input.readTag();
408 if (tag == 0 || !mergeFieldFrom(tag, input)) { 372 if (tag == 0 || !mergeFieldFrom(tag, input)) {
409 break; 373 break;
410 } 374 }
411 } 375 }
412 return this; 376 return this;
413 } 377 }
414 } 378 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698