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

Commit

Permalink
Sync changes from internal repo. (#100)
Browse files Browse the repository at this point in the history
* Small performance tweak for DDC.
  • Loading branch information
jakobr-google authored Feb 22, 2018
1 parent 2afec1a commit c521d3d
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 43 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.7.10 - 2018-02-22

* Small performance tweak for DDC.

## 0.7.9 - 2018-01-12

* Add fast getters for common types.
Expand Down
9 changes: 5 additions & 4 deletions lib/message_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,8 @@ class MessageGenerator extends ProtobufContainer {
var names = field.memberNames;

_emitOverrideIf(field.overridesGetter, out);
var getterExpr =
_getterExpression(fieldTypeString, field.index, defaultExpr);
var getterExpr = _getterExpression(
fieldTypeString, field.index, defaultExpr, field.isRepeated);
out.println('${fieldTypeString} get ${names.fieldName} => ${getterExpr};');

if (field.isRepeated) {
Expand Down Expand Up @@ -361,15 +361,16 @@ class MessageGenerator extends ProtobufContainer {
}
}

String _getterExpression(String fieldType, int index, String defaultExpr) {
String _getterExpression(
String fieldType, int index, String defaultExpr, bool isRepeated) {
if (fieldType == 'String') {
return '\$_getS($index, $defaultExpr)';
}
if (fieldType == 'Int64' && defaultExpr == 'null') {
return '\$_getI64($index)';
}
if (defaultExpr == 'null') {
return '\$_getN($index)';
return isRepeated ? '\$_getList($index)' : '\$_getN($index)';
}
return '\$_get($index, $defaultExpr)';
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/dart_options.pb.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class Imports extends GeneratedMessage {
if (v is! Imports) checkItemFailed(v, 'Imports');
}

List<DartMixin> get mixins => $_getN(0);
List<DartMixin> get mixins => $_getList(0);
}

class _ReadonlyImports extends Imports with ReadonlyMessageMixin {}
Expand Down
66 changes: 33 additions & 33 deletions lib/src/descriptor.pb.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class FileDescriptorSet extends GeneratedMessage {
if (v is! FileDescriptorSet) checkItemFailed(v, 'FileDescriptorSet');
}

List<FileDescriptorProto> get file => $_getN(0);
List<FileDescriptorProto> get file => $_getList(0);
}

class _ReadonlyFileDescriptorSet extends FileDescriptorSet
Expand Down Expand Up @@ -109,15 +109,15 @@ class FileDescriptorProto extends GeneratedMessage {
bool hasPackage() => $_has(1);
void clearPackage() => clearField(2);

List<String> get dependency => $_getN(2);
List<String> get dependency => $_getList(2);

List<DescriptorProto> get messageType => $_getN(3);
List<DescriptorProto> get messageType => $_getList(3);

List<EnumDescriptorProto> get enumType => $_getN(4);
List<EnumDescriptorProto> get enumType => $_getList(4);

List<ServiceDescriptorProto> get service => $_getN(5);
List<ServiceDescriptorProto> get service => $_getList(5);

List<FieldDescriptorProto> get extension => $_getN(6);
List<FieldDescriptorProto> get extension => $_getList(6);

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

List<int> get publicDependency => $_getN(9);
List<int> get publicDependency => $_getList(9);

List<int> get weakDependency => $_getN(10);
List<int> get weakDependency => $_getList(10);

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

List<FieldDescriptorProto> get field => $_getN(1);
List<FieldDescriptorProto> get field => $_getList(1);

List<DescriptorProto> get nestedType => $_getN(2);
List<DescriptorProto> get nestedType => $_getList(2);

List<EnumDescriptorProto> get enumType => $_getN(3);
List<EnumDescriptorProto> get enumType => $_getList(3);

List<DescriptorProto_ExtensionRange> get extensionRange => $_getN(4);
List<DescriptorProto_ExtensionRange> get extensionRange => $_getList(4);

List<FieldDescriptorProto> get extension => $_getN(5);
List<FieldDescriptorProto> get extension => $_getList(5);

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

List<OneofDescriptorProto> get oneofDecl => $_getN(7);
List<OneofDescriptorProto> get oneofDecl => $_getList(7);

List<DescriptorProto_ReservedRange> get reservedRange => $_getN(8);
List<DescriptorProto_ReservedRange> get reservedRange => $_getList(8);

List<String> get reservedName => $_getN(9);
List<String> get reservedName => $_getList(9);
}

class _ReadonlyDescriptorProto extends DescriptorProto
Expand Down Expand Up @@ -568,7 +568,7 @@ class EnumDescriptorProto extends GeneratedMessage {
bool hasName() => $_has(0);
void clearName() => clearField(1);

List<EnumValueDescriptorProto> get value => $_getN(1);
List<EnumValueDescriptorProto> get value => $_getList(1);

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

List<MethodDescriptorProto> get method => $_getN(1);
List<MethodDescriptorProto> get method => $_getList(1);

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

List<UninterpretedOption> get uninterpretedOption => $_getN(17);
List<UninterpretedOption> get uninterpretedOption => $_getList(17);
}

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

List<UninterpretedOption> get uninterpretedOption => $_getN(4);
List<UninterpretedOption> get uninterpretedOption => $_getList(4);
}

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

List<UninterpretedOption> get uninterpretedOption => $_getN(6);
List<UninterpretedOption> get uninterpretedOption => $_getList(6);
}

class _ReadonlyFieldOptions extends FieldOptions with ReadonlyMessageMixin {}
Expand Down Expand Up @@ -1173,7 +1173,7 @@ class OneofOptions extends GeneratedMessage {
if (v is! OneofOptions) checkItemFailed(v, 'OneofOptions');
}

List<UninterpretedOption> get uninterpretedOption => $_getN(0);
List<UninterpretedOption> get uninterpretedOption => $_getList(0);
}

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

List<UninterpretedOption> get uninterpretedOption => $_getN(2);
List<UninterpretedOption> get uninterpretedOption => $_getList(2);
}

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

List<UninterpretedOption> get uninterpretedOption => $_getN(1);
List<UninterpretedOption> get uninterpretedOption => $_getList(1);
}

class _ReadonlyEnumValueOptions extends EnumValueOptions
Expand Down Expand Up @@ -1310,7 +1310,7 @@ class ServiceOptions extends GeneratedMessage {
bool hasDeprecated() => $_has(0);
void clearDeprecated() => clearField(33);

List<UninterpretedOption> get uninterpretedOption => $_getN(1);
List<UninterpretedOption> get uninterpretedOption => $_getList(1);
}

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

List<UninterpretedOption> get uninterpretedOption => $_getN(2);
List<UninterpretedOption> get uninterpretedOption => $_getList(2);
}

class _ReadonlyMethodOptions extends MethodOptions with ReadonlyMessageMixin {}
Expand Down Expand Up @@ -1463,7 +1463,7 @@ class UninterpretedOption extends GeneratedMessage {
if (v is! UninterpretedOption) checkItemFailed(v, 'UninterpretedOption');
}

List<UninterpretedOption_NamePart> get name => $_getN(0);
List<UninterpretedOption_NamePart> get name => $_getList(0);

String get identifierValue => $_getS(1, '');
set identifierValue(String v) {
Expand Down Expand Up @@ -1551,9 +1551,9 @@ class SourceCodeInfo_Location extends GeneratedMessage {
checkItemFailed(v, 'SourceCodeInfo_Location');
}

List<int> get path => $_getN(0);
List<int> get path => $_getList(0);

List<int> get span => $_getN(1);
List<int> get span => $_getList(1);

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

List<String> get leadingDetachedComments => $_getN(4);
List<String> get leadingDetachedComments => $_getList(4);
}

class _ReadonlySourceCodeInfo_Location extends SourceCodeInfo_Location
Expand Down Expand Up @@ -1606,7 +1606,7 @@ class SourceCodeInfo extends GeneratedMessage {
if (v is! SourceCodeInfo) checkItemFailed(v, 'SourceCodeInfo');
}

List<SourceCodeInfo_Location> get location => $_getN(0);
List<SourceCodeInfo_Location> get location => $_getList(0);
}

class _ReadonlySourceCodeInfo extends SourceCodeInfo with ReadonlyMessageMixin {
Expand Down Expand Up @@ -1646,7 +1646,7 @@ class GeneratedCodeInfo_Annotation extends GeneratedMessage {
checkItemFailed(v, 'GeneratedCodeInfo_Annotation');
}

List<int> get path => $_getN(0);
List<int> get path => $_getList(0);

String get sourceFile => $_getS(1, '');
set sourceFile(String v) {
Expand Down Expand Up @@ -1709,7 +1709,7 @@ class GeneratedCodeInfo extends GeneratedMessage {
if (v is! GeneratedCodeInfo) checkItemFailed(v, 'GeneratedCodeInfo');
}

List<GeneratedCodeInfo_Annotation> get annotation => $_getN(0);
List<GeneratedCodeInfo_Annotation> get annotation => $_getList(0);
}

class _ReadonlyGeneratedCodeInfo extends GeneratedCodeInfo
Expand Down
6 changes: 3 additions & 3 deletions lib/src/plugin.pb.dart
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class CodeGeneratorRequest extends GeneratedMessage {
if (v is! CodeGeneratorRequest) checkItemFailed(v, 'CodeGeneratorRequest');
}

List<String> get fileToGenerate => $_getN(0);
List<String> get fileToGenerate => $_getList(0);

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

List<$google$protobuf.FileDescriptorProto> get protoFile => $_getN(3);
List<$google$protobuf.FileDescriptorProto> get protoFile => $_getList(3);
}

class _ReadonlyCodeGeneratorRequest extends CodeGeneratorRequest
Expand Down Expand Up @@ -240,7 +240,7 @@ class CodeGeneratorResponse extends GeneratedMessage {
bool hasError() => $_has(0);
void clearError() => clearField(1);

List<CodeGeneratorResponse_File> get file => $_getN(1);
List<CodeGeneratorResponse_File> get file => $_getList(1);
}

class _ReadonlyCodeGeneratorResponse extends CodeGeneratorResponse
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: protoc_plugin
version: 0.7.9
version: 0.7.10
author: Dart Team <[email protected]>
description: Protoc compiler plugin to generate Dart code
homepage: https://github.com/dart-lang/dart-protoc-plugin
Expand All @@ -8,7 +8,7 @@ environment:
dependencies:
fixnum: ^0.10.5
path: ^1.0.0
protobuf: ^0.7.0
protobuf: ^0.7.1
dart_style: ^1.0.6
dev_dependencies:
browser: any
Expand Down

0 comments on commit c521d3d

Please sign in to comment.