Skip to content
This repository was archived by the owner on Jan 26, 2021. It is now read-only.

Commit c521d3d

Browse files
Sync changes from internal repo. (#100)
* Small performance tweak for DDC.
1 parent 2afec1a commit c521d3d

File tree

6 files changed

+48
-43
lines changed

6 files changed

+48
-43
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.7.10 - 2018-02-22
2+
3+
* Small performance tweak for DDC.
4+
15
## 0.7.9 - 2018-01-12
26

37
* Add fast getters for common types.

lib/message_generator.dart

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,8 @@ class MessageGenerator extends ProtobufContainer {
321321
var names = field.memberNames;
322322

323323
_emitOverrideIf(field.overridesGetter, out);
324-
var getterExpr =
325-
_getterExpression(fieldTypeString, field.index, defaultExpr);
324+
var getterExpr = _getterExpression(
325+
fieldTypeString, field.index, defaultExpr, field.isRepeated);
326326
out.println('${fieldTypeString} get ${names.fieldName} => ${getterExpr};');
327327

328328
if (field.isRepeated) {
@@ -361,15 +361,16 @@ class MessageGenerator extends ProtobufContainer {
361361
}
362362
}
363363

364-
String _getterExpression(String fieldType, int index, String defaultExpr) {
364+
String _getterExpression(
365+
String fieldType, int index, String defaultExpr, bool isRepeated) {
365366
if (fieldType == 'String') {
366367
return '\$_getS($index, $defaultExpr)';
367368
}
368369
if (fieldType == 'Int64' && defaultExpr == 'null') {
369370
return '\$_getI64($index)';
370371
}
371372
if (defaultExpr == 'null') {
372-
return '\$_getN($index)';
373+
return isRepeated ? '\$_getList($index)' : '\$_getN($index)';
373374
}
374375
return '\$_get($index, $defaultExpr)';
375376
}

lib/src/dart_options.pb.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class Imports extends GeneratedMessage {
8989
if (v is! Imports) checkItemFailed(v, 'Imports');
9090
}
9191

92-
List<DartMixin> get mixins => $_getN(0);
92+
List<DartMixin> get mixins => $_getList(0);
9393
}
9494

9595
class _ReadonlyImports extends Imports with ReadonlyMessageMixin {}

lib/src/descriptor.pb.dart

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class FileDescriptorSet extends GeneratedMessage {
4242
if (v is! FileDescriptorSet) checkItemFailed(v, 'FileDescriptorSet');
4343
}
4444

45-
List<FileDescriptorProto> get file => $_getN(0);
45+
List<FileDescriptorProto> get file => $_getList(0);
4646
}
4747

4848
class _ReadonlyFileDescriptorSet extends FileDescriptorSet
@@ -109,15 +109,15 @@ class FileDescriptorProto extends GeneratedMessage {
109109
bool hasPackage() => $_has(1);
110110
void clearPackage() => clearField(2);
111111

112-
List<String> get dependency => $_getN(2);
112+
List<String> get dependency => $_getList(2);
113113

114-
List<DescriptorProto> get messageType => $_getN(3);
114+
List<DescriptorProto> get messageType => $_getList(3);
115115

116-
List<EnumDescriptorProto> get enumType => $_getN(4);
116+
List<EnumDescriptorProto> get enumType => $_getList(4);
117117

118-
List<ServiceDescriptorProto> get service => $_getN(5);
118+
List<ServiceDescriptorProto> get service => $_getList(5);
119119

120-
List<FieldDescriptorProto> get extension => $_getN(6);
120+
List<FieldDescriptorProto> get extension => $_getList(6);
121121

122122
FileOptions get options => $_getN(7);
123123
set options(FileOptions v) {
@@ -135,9 +135,9 @@ class FileDescriptorProto extends GeneratedMessage {
135135
bool hasSourceCodeInfo() => $_has(8);
136136
void clearSourceCodeInfo() => clearField(9);
137137

138-
List<int> get publicDependency => $_getN(9);
138+
List<int> get publicDependency => $_getList(9);
139139

140-
List<int> get weakDependency => $_getN(10);
140+
List<int> get weakDependency => $_getList(10);
141141

142142
String get syntax => $_getS(11, '');
143143
set syntax(String v) {
@@ -316,15 +316,15 @@ class DescriptorProto extends GeneratedMessage {
316316
bool hasName() => $_has(0);
317317
void clearName() => clearField(1);
318318

319-
List<FieldDescriptorProto> get field => $_getN(1);
319+
List<FieldDescriptorProto> get field => $_getList(1);
320320

321-
List<DescriptorProto> get nestedType => $_getN(2);
321+
List<DescriptorProto> get nestedType => $_getList(2);
322322

323-
List<EnumDescriptorProto> get enumType => $_getN(3);
323+
List<EnumDescriptorProto> get enumType => $_getList(3);
324324

325-
List<DescriptorProto_ExtensionRange> get extensionRange => $_getN(4);
325+
List<DescriptorProto_ExtensionRange> get extensionRange => $_getList(4);
326326

327-
List<FieldDescriptorProto> get extension => $_getN(5);
327+
List<FieldDescriptorProto> get extension => $_getList(5);
328328

329329
MessageOptions get options => $_getN(6);
330330
set options(MessageOptions v) {
@@ -334,11 +334,11 @@ class DescriptorProto extends GeneratedMessage {
334334
bool hasOptions() => $_has(6);
335335
void clearOptions() => clearField(7);
336336

337-
List<OneofDescriptorProto> get oneofDecl => $_getN(7);
337+
List<OneofDescriptorProto> get oneofDecl => $_getList(7);
338338

339-
List<DescriptorProto_ReservedRange> get reservedRange => $_getN(8);
339+
List<DescriptorProto_ReservedRange> get reservedRange => $_getList(8);
340340

341-
List<String> get reservedName => $_getN(9);
341+
List<String> get reservedName => $_getList(9);
342342
}
343343

344344
class _ReadonlyDescriptorProto extends DescriptorProto
@@ -568,7 +568,7 @@ class EnumDescriptorProto extends GeneratedMessage {
568568
bool hasName() => $_has(0);
569569
void clearName() => clearField(1);
570570

571-
List<EnumValueDescriptorProto> get value => $_getN(1);
571+
List<EnumValueDescriptorProto> get value => $_getList(1);
572572

573573
EnumOptions get options => $_getN(2);
574574
set options(EnumOptions v) {
@@ -683,7 +683,7 @@ class ServiceDescriptorProto extends GeneratedMessage {
683683
bool hasName() => $_has(0);
684684
void clearName() => clearField(1);
685685

686-
List<MethodDescriptorProto> get method => $_getN(1);
686+
List<MethodDescriptorProto> get method => $_getList(1);
687687

688688
ServiceOptions get options => $_getN(2);
689689
set options(ServiceOptions v) {
@@ -970,7 +970,7 @@ class FileOptions extends GeneratedMessage {
970970
bool hasPhpNamespace() => $_has(16);
971971
void clearPhpNamespace() => clearField(41);
972972

973-
List<UninterpretedOption> get uninterpretedOption => $_getN(17);
973+
List<UninterpretedOption> get uninterpretedOption => $_getList(17);
974974
}
975975

976976
class _ReadonlyFileOptions extends FileOptions with ReadonlyMessageMixin {}
@@ -1040,7 +1040,7 @@ class MessageOptions extends GeneratedMessage {
10401040
bool hasMapEntry() => $_has(3);
10411041
void clearMapEntry() => clearField(7);
10421042

1043-
List<UninterpretedOption> get uninterpretedOption => $_getN(4);
1043+
List<UninterpretedOption> get uninterpretedOption => $_getList(4);
10441044
}
10451045

10461046
class _ReadonlyMessageOptions extends MessageOptions with ReadonlyMessageMixin {
@@ -1140,7 +1140,7 @@ class FieldOptions extends GeneratedMessage {
11401140
bool hasWeak() => $_has(5);
11411141
void clearWeak() => clearField(10);
11421142

1143-
List<UninterpretedOption> get uninterpretedOption => $_getN(6);
1143+
List<UninterpretedOption> get uninterpretedOption => $_getList(6);
11441144
}
11451145

11461146
class _ReadonlyFieldOptions extends FieldOptions with ReadonlyMessageMixin {}
@@ -1173,7 +1173,7 @@ class OneofOptions extends GeneratedMessage {
11731173
if (v is! OneofOptions) checkItemFailed(v, 'OneofOptions');
11741174
}
11751175

1176-
List<UninterpretedOption> get uninterpretedOption => $_getN(0);
1176+
List<UninterpretedOption> get uninterpretedOption => $_getList(0);
11771177
}
11781178

11791179
class _ReadonlyOneofOptions extends OneofOptions with ReadonlyMessageMixin {}
@@ -1223,7 +1223,7 @@ class EnumOptions extends GeneratedMessage {
12231223
bool hasDeprecated() => $_has(1);
12241224
void clearDeprecated() => clearField(3);
12251225

1226-
List<UninterpretedOption> get uninterpretedOption => $_getN(2);
1226+
List<UninterpretedOption> get uninterpretedOption => $_getList(2);
12271227
}
12281228

12291229
class _ReadonlyEnumOptions extends EnumOptions with ReadonlyMessageMixin {}
@@ -1266,7 +1266,7 @@ class EnumValueOptions extends GeneratedMessage {
12661266
bool hasDeprecated() => $_has(0);
12671267
void clearDeprecated() => clearField(1);
12681268

1269-
List<UninterpretedOption> get uninterpretedOption => $_getN(1);
1269+
List<UninterpretedOption> get uninterpretedOption => $_getList(1);
12701270
}
12711271

12721272
class _ReadonlyEnumValueOptions extends EnumValueOptions
@@ -1310,7 +1310,7 @@ class ServiceOptions extends GeneratedMessage {
13101310
bool hasDeprecated() => $_has(0);
13111311
void clearDeprecated() => clearField(33);
13121312

1313-
List<UninterpretedOption> get uninterpretedOption => $_getN(1);
1313+
List<UninterpretedOption> get uninterpretedOption => $_getList(1);
13141314
}
13151315

13161316
class _ReadonlyServiceOptions extends ServiceOptions with ReadonlyMessageMixin {
@@ -1368,7 +1368,7 @@ class MethodOptions extends GeneratedMessage {
13681368
bool hasIdempotencyLevel() => $_has(1);
13691369
void clearIdempotencyLevel() => clearField(34);
13701370

1371-
List<UninterpretedOption> get uninterpretedOption => $_getN(2);
1371+
List<UninterpretedOption> get uninterpretedOption => $_getList(2);
13721372
}
13731373

13741374
class _ReadonlyMethodOptions extends MethodOptions with ReadonlyMessageMixin {}
@@ -1463,7 +1463,7 @@ class UninterpretedOption extends GeneratedMessage {
14631463
if (v is! UninterpretedOption) checkItemFailed(v, 'UninterpretedOption');
14641464
}
14651465

1466-
List<UninterpretedOption_NamePart> get name => $_getN(0);
1466+
List<UninterpretedOption_NamePart> get name => $_getList(0);
14671467

14681468
String get identifierValue => $_getS(1, '');
14691469
set identifierValue(String v) {
@@ -1551,9 +1551,9 @@ class SourceCodeInfo_Location extends GeneratedMessage {
15511551
checkItemFailed(v, 'SourceCodeInfo_Location');
15521552
}
15531553

1554-
List<int> get path => $_getN(0);
1554+
List<int> get path => $_getList(0);
15551555

1556-
List<int> get span => $_getN(1);
1556+
List<int> get span => $_getList(1);
15571557

15581558
String get leadingComments => $_getS(2, '');
15591559
set leadingComments(String v) {
@@ -1571,7 +1571,7 @@ class SourceCodeInfo_Location extends GeneratedMessage {
15711571
bool hasTrailingComments() => $_has(3);
15721572
void clearTrailingComments() => clearField(4);
15731573

1574-
List<String> get leadingDetachedComments => $_getN(4);
1574+
List<String> get leadingDetachedComments => $_getList(4);
15751575
}
15761576

15771577
class _ReadonlySourceCodeInfo_Location extends SourceCodeInfo_Location
@@ -1606,7 +1606,7 @@ class SourceCodeInfo extends GeneratedMessage {
16061606
if (v is! SourceCodeInfo) checkItemFailed(v, 'SourceCodeInfo');
16071607
}
16081608

1609-
List<SourceCodeInfo_Location> get location => $_getN(0);
1609+
List<SourceCodeInfo_Location> get location => $_getList(0);
16101610
}
16111611

16121612
class _ReadonlySourceCodeInfo extends SourceCodeInfo with ReadonlyMessageMixin {
@@ -1646,7 +1646,7 @@ class GeneratedCodeInfo_Annotation extends GeneratedMessage {
16461646
checkItemFailed(v, 'GeneratedCodeInfo_Annotation');
16471647
}
16481648

1649-
List<int> get path => $_getN(0);
1649+
List<int> get path => $_getList(0);
16501650

16511651
String get sourceFile => $_getS(1, '');
16521652
set sourceFile(String v) {
@@ -1709,7 +1709,7 @@ class GeneratedCodeInfo extends GeneratedMessage {
17091709
if (v is! GeneratedCodeInfo) checkItemFailed(v, 'GeneratedCodeInfo');
17101710
}
17111711

1712-
List<GeneratedCodeInfo_Annotation> get annotation => $_getN(0);
1712+
List<GeneratedCodeInfo_Annotation> get annotation => $_getList(0);
17131713
}
17141714

17151715
class _ReadonlyGeneratedCodeInfo extends GeneratedCodeInfo

lib/src/plugin.pb.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ class CodeGeneratorRequest extends GeneratedMessage {
111111
if (v is! CodeGeneratorRequest) checkItemFailed(v, 'CodeGeneratorRequest');
112112
}
113113

114-
List<String> get fileToGenerate => $_getN(0);
114+
List<String> get fileToGenerate => $_getList(0);
115115

116116
String get parameter => $_getS(1, '');
117117
set parameter(String v) {
@@ -129,7 +129,7 @@ class CodeGeneratorRequest extends GeneratedMessage {
129129
bool hasCompilerVersion() => $_has(2);
130130
void clearCompilerVersion() => clearField(3);
131131

132-
List<$google$protobuf.FileDescriptorProto> get protoFile => $_getN(3);
132+
List<$google$protobuf.FileDescriptorProto> get protoFile => $_getList(3);
133133
}
134134

135135
class _ReadonlyCodeGeneratorRequest extends CodeGeneratorRequest
@@ -240,7 +240,7 @@ class CodeGeneratorResponse extends GeneratedMessage {
240240
bool hasError() => $_has(0);
241241
void clearError() => clearField(1);
242242

243-
List<CodeGeneratorResponse_File> get file => $_getN(1);
243+
List<CodeGeneratorResponse_File> get file => $_getList(1);
244244
}
245245

246246
class _ReadonlyCodeGeneratorResponse extends CodeGeneratorResponse

pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: protoc_plugin
2-
version: 0.7.9
2+
version: 0.7.10
33
author: Dart Team <[email protected]>
44
description: Protoc compiler plugin to generate Dart code
55
homepage: https://github.com/dart-lang/dart-protoc-plugin
@@ -8,7 +8,7 @@ environment:
88
dependencies:
99
fixnum: ^0.10.5
1010
path: ^1.0.0
11-
protobuf: ^0.7.0
11+
protobuf: ^0.7.1
1212
dart_style: ^1.0.6
1313
dev_dependencies:
1414
browser: any

0 commit comments

Comments
 (0)