Skip to content

Commit 08f1e48

Browse files
echistyakovfacebook-github-bot
authored andcommitted
Disable DefaultGet generation by default
Summary: Disable `DefaultGet` method generation by default. This improves compilation speed for 99.9% of users (except for two schemas that still rely on this deprecated method). Reviewed By: a-lafrance Differential Revision: D74601226 fbshipit-source-id: 5464a5368b3530e7b2269ad4bdf60b74c93915ed
1 parent 5d43796 commit 08f1e48

File tree

22 files changed

+1
-603
lines changed
  • third-party/thrift/src/thrift/compiler
    • generate/go
    • test/fixtures
      • adapter/out/go/gen-go/module
      • basic-annotations/out/go/gen-go/module
      • basic/out/go/gen-go/module
      • complex-union/out/go/gen-go/module
      • constants/out/go/gen-go/module
      • default_values_rectification_after/out/go/gen-go/module
      • default_values_rectification_before/out/go/gen-go/module
      • default_values/out/go/gen-go/module
      • doctext/out/go/gen-go/module
      • exceptions/out/go/gen-go/module
      • go-service/out/go/gen-go/module
      • go-typedef/out/go_module1/gen-go/module1
      • includes/out
      • interactions/out/go/gen-go/module
      • namespace/out/go_extend/gen-go/my/namespacing/extend/test
      • optionals/out/go/gen-go/module
      • terse_write/out/go/gen-go/terse_write
      • types/out/go/gen-go/module

22 files changed

+1
-603
lines changed

third-party/thrift/src/thrift/compiler/generate/go/util.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class codegen_data {
4343
// whether to generate Thrift metadata
4444
bool gen_metadata = true;
4545
// whether to generate DefaultGet method
46-
bool gen_default_get = true;
46+
bool gen_default_get = false;
4747
// whether to use reflect codec
4848
bool use_reflect_codec = false;
4949

third-party/thrift/src/thrift/compiler/test/fixtures/adapter/out/go/gen-go/module/types.go

Lines changed: 0 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -3295,45 +3295,10 @@ func (x *Bar) readField7(p thrift.Decoder) error { // AdaptedStructField
32953295
return nil
32963296
}
32973297

3298-
// Deprecated: Use NewBar().GetStructField() instead.
3299-
func (x *Bar) DefaultGetStructField() *Foo_6868 {
3300-
if !x.IsSetStructField() {
3301-
return NewFoo_6868()
3302-
}
3303-
return x.StructField
3304-
}
33053298

3306-
// Deprecated: Use NewBar().GetOptionalStructField() instead.
3307-
func (x *Bar) DefaultGetOptionalStructField() *Foo_3943 {
3308-
if !x.IsSetOptionalStructField() {
3309-
return NewFoo_3943()
3310-
}
3311-
return x.OptionalStructField
3312-
}
33133299

3314-
// Deprecated: Use NewBar().GetUnionField() instead.
3315-
func (x *Bar) DefaultGetUnionField() *Baz_7352 {
3316-
if !x.IsSetUnionField() {
3317-
return NewBaz_7352()
3318-
}
3319-
return x.UnionField
3320-
}
33213300

3322-
// Deprecated: Use NewBar().GetOptionalUnionField() instead.
3323-
func (x *Bar) DefaultGetOptionalUnionField() *Baz_7352 {
3324-
if !x.IsSetOptionalUnionField() {
3325-
return NewBaz_7352()
3326-
}
3327-
return x.OptionalUnionField
3328-
}
33293301

3330-
// Deprecated: Use NewBar().GetAdaptedStructField() instead.
3331-
func (x *Bar) DefaultGetAdaptedStructField() *DirectlyAdapted {
3332-
if !x.IsSetAdaptedStructField() {
3333-
return NewDirectlyAdapted()
3334-
}
3335-
return x.AdaptedStructField
3336-
}
33373302

33383303

33393304

@@ -4268,13 +4233,6 @@ func (x *B) readField1(p thrift.Decoder) error { // A
42684233
return nil
42694234
}
42704235

4271-
// Deprecated: Use NewB().GetA() instead.
4272-
func (x *B) DefaultGetA() *AdaptedA {
4273-
if !x.IsSetA() {
4274-
return NewAdaptedA()
4275-
}
4276-
return x.A
4277-
}
42784236

42794237

42804238

@@ -6725,13 +6683,6 @@ func (x *AdaptTemplatedNestedTestStruct) readField1(p thrift.Decoder) error { /
67256683
return nil
67266684
}
67276685

6728-
// Deprecated: Use NewAdaptTemplatedNestedTestStruct().GetAdaptedStruct() instead.
6729-
func (x *AdaptTemplatedNestedTestStruct) DefaultGetAdaptedStruct() *AdaptTemplatedTestStruct {
6730-
if !x.IsSetAdaptedStruct() {
6731-
return NewAdaptTemplatedTestStruct()
6732-
}
6733-
return x.AdaptedStruct
6734-
}
67356686

67366687

67376688

@@ -7468,37 +7419,9 @@ func (x *StructFieldAdaptedStruct) readField4(p thrift.Decoder) error { // Type
74687419
return nil
74697420
}
74707421

7471-
// Deprecated: Use NewStructFieldAdaptedStruct().GetAdaptedStruct() instead.
7472-
func (x *StructFieldAdaptedStruct) DefaultGetAdaptedStruct() *AdaptedStruct {
7473-
if !x.IsSetAdaptedStruct() {
7474-
return NewAdaptedStruct()
7475-
}
7476-
return x.AdaptedStruct
7477-
}
74787422

7479-
// Deprecated: Use NewStructFieldAdaptedStruct().GetAdaptedTypedef() instead.
7480-
func (x *StructFieldAdaptedStruct) DefaultGetAdaptedTypedef() *AdaptedTypedef {
7481-
if !x.IsSetAdaptedTypedef() {
7482-
return NewAdaptedTypedef()
7483-
}
7484-
return x.AdaptedTypedef
7485-
}
74867423

7487-
// Deprecated: Use NewStructFieldAdaptedStruct().GetDirectlyAdapted() instead.
7488-
func (x *StructFieldAdaptedStruct) DefaultGetDirectlyAdapted() *DirectlyAdaptedStruct {
7489-
if !x.IsSetDirectlyAdapted() {
7490-
return NewDirectlyAdaptedStruct()
7491-
}
7492-
return x.DirectlyAdapted
7493-
}
74947424

7495-
// Deprecated: Use NewStructFieldAdaptedStruct().GetTypedefOfAdapted() instead.
7496-
func (x *StructFieldAdaptedStruct) DefaultGetTypedefOfAdapted() *TypedefOfDirect {
7497-
if !x.IsSetTypedefOfAdapted() {
7498-
return NewTypedefOfDirect()
7499-
}
7500-
return x.TypedefOfAdapted
7501-
}
75027425

75037426

75047427

@@ -7649,13 +7572,6 @@ func (x *CircularAdaptee) readField1(p thrift.Decoder) error { // Field
76497572
return nil
76507573
}
76517574

7652-
// Deprecated: Use NewCircularAdaptee().GetField() instead.
7653-
func (x *CircularAdaptee) DefaultGetField() *CircularStruct {
7654-
if !x.IsSetField() {
7655-
return NewCircularStruct()
7656-
}
7657-
return x.Field
7658-
}
76597575

76607576

76617577

@@ -7788,13 +7704,6 @@ func (x *CircularStruct) readField1(p thrift.Decoder) error { // Field
77887704
return nil
77897705
}
77907706

7791-
// Deprecated: Use NewCircularStruct().GetField() instead.
7792-
func (x *CircularStruct) DefaultGetField() *AdaptedCircularAdaptee {
7793-
if !x.IsSetField() {
7794-
return NewAdaptedCircularAdaptee()
7795-
}
7796-
return x.Field
7797-
}
77987707

77997708

78007709

@@ -7926,13 +7835,6 @@ func (x *ReorderedStruct) readField1(p thrift.Decoder) error { // ReorderedDepe
79267835
return nil
79277836
}
79287837

7929-
// Deprecated: Use NewReorderedStruct().GetReorderedDependentAdapted() instead.
7930-
func (x *ReorderedStruct) DefaultGetReorderedDependentAdapted() *DeclaredAfterStruct {
7931-
if !x.IsSetReorderedDependentAdapted() {
7932-
return NewDeclaredAfterStruct()
7933-
}
7934-
return x.ReorderedDependentAdapted
7935-
}
79367838

79377839

79387840

@@ -8447,13 +8349,6 @@ func (x *MoveOnly) readField1(p thrift.Decoder) error { // Ptr
84478349
return nil
84488350
}
84498351

8450-
// Deprecated: Use NewMoveOnly().GetPtr() instead.
8451-
func (x *MoveOnly) DefaultGetPtr() *HeapAllocated {
8452-
if !x.IsSetPtr() {
8453-
return NewHeapAllocated()
8454-
}
8455-
return x.Ptr
8456-
}
84578352

84588353

84598354

@@ -9541,13 +9436,6 @@ func (x *reqServiceFunc) readField3(p thrift.Decoder) error { // Arg3
95419436
return nil
95429437
}
95439438

9544-
// Deprecated: Use newReqServiceFunc().GetArg3() instead.
9545-
func (x *reqServiceFunc) DefaultGetArg3() *Foo {
9546-
if !x.IsSetArg3() {
9547-
return NewFoo()
9548-
}
9549-
return x.Arg3
9550-
}
95519439

95529440

95539441

@@ -9910,13 +9798,6 @@ func (x *respAdapterServiceCount) readField0(p thrift.Decoder) error { // Succe
99109798
return nil
99119799
}
99129800

9913-
// Deprecated: Use newRespAdapterServiceCount().GetSuccess() instead.
9914-
func (x *respAdapterServiceCount) DefaultGetSuccess() *CountingStruct {
9915-
if !x.IsSetSuccess() {
9916-
return NewCountingStruct()
9917-
}
9918-
return x.Success
9919-
}
99209801

99219802

99229803

@@ -10055,13 +9936,6 @@ func (x *reqAdapterServiceAdaptedTypes) readField1(p thrift.Decoder) error { //
100559936
return nil
100569937
}
100579938

10058-
// Deprecated: Use newReqAdapterServiceAdaptedTypes().GetArg() instead.
10059-
func (x *reqAdapterServiceAdaptedTypes) DefaultGetArg() *HeapAllocated {
10060-
if !x.IsSetArg() {
10061-
return NewHeapAllocated()
10062-
}
10063-
return x.Arg
10064-
}
100659939

100669940

100679941

@@ -10198,13 +10072,6 @@ func (x *respAdapterServiceAdaptedTypes) readField0(p thrift.Decoder) error { /
1019810072
return nil
1019910073
}
1020010074

10201-
// Deprecated: Use newRespAdapterServiceAdaptedTypes().GetSuccess() instead.
10202-
func (x *respAdapterServiceAdaptedTypes) DefaultGetSuccess() *HeapAllocated {
10203-
if !x.IsSetSuccess() {
10204-
return NewHeapAllocated()
10205-
}
10206-
return x.Success
10207-
}
1020810075

1020910076

1021010077

third-party/thrift/src/thrift/compiler/test/fixtures/basic-annotations/out/go/gen-go/module/types.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -842,13 +842,6 @@ func (x *MyStruct) readField9(p thrift.Decoder) error { // MyUnion
842842
return nil
843843
}
844844

845-
// Deprecated: Use NewMyStruct().GetMyUnion() instead.
846-
func (x *MyStruct) DefaultGetMyUnion() *MyUnion {
847-
if !x.IsSetMyUnion() {
848-
return NewMyUnion()
849-
}
850-
return x.MyUnion
851-
}
852845

853846

854847

@@ -1276,13 +1269,6 @@ func (x *respMyServicePing) readField1(p thrift.Decoder) error { // MyExcept
12761269
return nil
12771270
}
12781271

1279-
// Deprecated: Use newRespMyServicePing().GetMyExcept() instead.
1280-
func (x *respMyServicePing) DefaultGetMyExcept() *MyException {
1281-
if !x.IsSetMyExcept() {
1282-
return NewMyException()
1283-
}
1284-
return x.MyExcept
1285-
}
12861272

12871273

12881274

third-party/thrift/src/thrift/compiler/test/fixtures/basic/out/go/gen-go/module/types.go

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -586,13 +586,6 @@ func (x *MyStruct) readField9(p thrift.Decoder) error { // NoHackCodegenField
586586
return nil
587587
}
588588

589-
// Deprecated: Use NewMyStruct().GetMyDataField() instead.
590-
func (x *MyStruct) DefaultGetMyDataField() *MyDataItemAlias {
591-
if !x.IsSetMyDataField() {
592-
return NewMyDataItemAlias()
593-
}
594-
return x.MyDataField
595-
}
596589

597590

598591

@@ -1371,21 +1364,7 @@ func (x *MyUnion) readField4(p thrift.Decoder) error { // FloatSet
13711364
}
13721365

13731366

1374-
// Deprecated: Use NewMyUnion().GetMyStruct() instead.
1375-
func (x *MyUnion) DefaultGetMyStruct() *MyStruct {
1376-
if !x.IsSetMyStruct() {
1377-
return NewMyStruct()
1378-
}
1379-
return x.MyStruct
1380-
}
13811367

1382-
// Deprecated: Use NewMyUnion().GetMyDataItem() instead.
1383-
func (x *MyUnion) DefaultGetMyDataItem() *MyDataItem {
1384-
if !x.IsSetMyDataItem() {
1385-
return NewMyDataItem()
1386-
}
1387-
return x.MyDataItem
1388-
}
13891368

13901369
func (x *MyUnion) countSetFields() int {
13911370
count := int(0)
@@ -1691,21 +1670,7 @@ func (x *MyException) readField4(p thrift.Decoder) error { // MyUnion
16911670
return nil
16921671
}
16931672

1694-
// Deprecated: Use NewMyException().GetMyStruct() instead.
1695-
func (x *MyException) DefaultGetMyStruct() *MyStruct {
1696-
if !x.IsSetMyStruct() {
1697-
return NewMyStruct()
1698-
}
1699-
return x.MyStruct
1700-
}
17011673

1702-
// Deprecated: Use NewMyException().GetMyUnion() instead.
1703-
func (x *MyException) DefaultGetMyUnion() *MyUnion {
1704-
if !x.IsSetMyUnion() {
1705-
return NewMyUnion()
1706-
}
1707-
return x.MyUnion
1708-
}
17091674

17101675

17111676

@@ -1994,21 +1959,7 @@ func (x *MyExceptionWithMessage) readField4(p thrift.Decoder) error { // MyUnio
19941959
return nil
19951960
}
19961961

1997-
// Deprecated: Use NewMyExceptionWithMessage().GetMyStruct() instead.
1998-
func (x *MyExceptionWithMessage) DefaultGetMyStruct() *MyStruct {
1999-
if !x.IsSetMyStruct() {
2000-
return NewMyStruct()
2001-
}
2002-
return x.MyStruct
2003-
}
20041962

2005-
// Deprecated: Use NewMyExceptionWithMessage().GetMyUnion() instead.
2006-
func (x *MyExceptionWithMessage) DefaultGetMyUnion() *MyUnion {
2007-
if !x.IsSetMyUnion() {
2008-
return NewMyUnion()
2009-
}
2010-
return x.MyUnion
2011-
}
20121963

20131964

20141965

@@ -2709,13 +2660,6 @@ func (x *respFB303ServiceSimpleRPC) readField0(p thrift.Decoder) error { // Suc
27092660
return nil
27102661
}
27112662

2712-
// Deprecated: Use newRespFB303ServiceSimpleRPC().GetSuccess() instead.
2713-
func (x *respFB303ServiceSimpleRPC) DefaultGetSuccess() *ReservedKeyword {
2714-
if !x.IsSetSuccess() {
2715-
return NewReservedKeyword()
2716-
}
2717-
return x.Success
2718-
}
27192663

27202664

27212665

third-party/thrift/src/thrift/compiler/test/fixtures/complex-union/out/go/gen-go/module/types.go

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1398,21 +1398,7 @@ func (x *ValUnion) readField2(p thrift.Decoder) error { // V2
13981398
return nil
13991399
}
14001400

1401-
// Deprecated: Use NewValUnion().GetV1() instead.
1402-
func (x *ValUnion) DefaultGetV1() *Val {
1403-
if !x.IsSetV1() {
1404-
return NewVal()
1405-
}
1406-
return x.V1
1407-
}
14081401

1409-
// Deprecated: Use NewValUnion().GetV2() instead.
1410-
func (x *ValUnion) DefaultGetV2() *Val {
1411-
if !x.IsSetV2() {
1412-
return NewVal()
1413-
}
1414-
return x.V2
1415-
}
14161402

14171403
func (x *ValUnion) countSetFields() int {
14181404
count := int(0)
@@ -1892,13 +1878,6 @@ func (x *NonCopyableUnion) readField1(p thrift.Decoder) error { // S
18921878
return nil
18931879
}
18941880

1895-
// Deprecated: Use NewNonCopyableUnion().GetS() instead.
1896-
func (x *NonCopyableUnion) DefaultGetS() *NonCopyableStruct {
1897-
if !x.IsSetS() {
1898-
return NewNonCopyableStruct()
1899-
}
1900-
return x.S
1901-
}
19021881

19031882
func (x *NonCopyableUnion) countSetFields() int {
19041883
count := int(0)

0 commit comments

Comments
 (0)