@@ -24,6 +24,7 @@ import (
2424 "os"
2525 "path/filepath"
2626 "reflect"
27+ "slices"
2728 "strings"
2829
2930 "github.com/hyperledger/firefly-common/pkg/fftypes"
@@ -892,17 +893,11 @@ func writeStructFields(ctx context.Context, t reflect.Type, rootPageNames, simpl
892893
893894 fieldInRootPages := false
894895 fieldInSimpleTypes := false
895- for _ , rootPageName := range rootPageNames {
896- if strings .ToLower (fieldType .Name ()) == rootPageName {
897- fieldInRootPages = true
898- break
899- }
896+ if slices .Contains (rootPageNames , strings .ToLower (fieldType .Name ())) {
897+ fieldInRootPages = true
900898 }
901- for _ , simpleTypeName := range simpleTypeNames {
902- if strings .ToLower (fieldType .Name ()) == simpleTypeName {
903- fieldInSimpleTypes = true
904- break
905- }
899+ if slices .Contains (simpleTypeNames , strings .ToLower (fieldType .Name ())) {
900+ fieldInSimpleTypes = true
906901 }
907902
908903 link := ""
@@ -920,13 +915,7 @@ func writeStructFields(ctx context.Context, t reflect.Type, rootPageNames, simpl
920915 fireflyType = fmt .Sprintf ("[%s](%s)" , fireflyType , link )
921916
922917 // Generate the table for the sub type
923- tableAlreadyGenerated := false
924- for _ , tableName := range generatedTableNames {
925- if strings .ToLower (fieldType .Name ()) == tableName {
926- tableAlreadyGenerated = true
927- break
928- }
929- }
918+ tableAlreadyGenerated := slices .Contains (generatedTableNames , strings .ToLower (fieldType .Name ()))
930919 if isStruct && ! tableAlreadyGenerated && ! fieldInRootPages && ! fieldInSimpleTypes {
931920 subFieldBuff .WriteString (fmt .Sprintf ("## %s\n \n " , fieldType .Name ()))
932921 subFieldMarkdown , newTableNames , _ := generateObjectReferenceMarkdown (ctx , false , nil , fieldType , rootPageNames , simpleTypeNames , generatedTableNames , outputPath )
0 commit comments