Skip to content

Commit c205ecd

Browse files
committed
Some minor cosmetics
Signed-off-by: Cristian Maglie <c.maglie@arduino.cc>
1 parent 14e2351 commit c205ecd

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/arduino.cc/builder/prototypes_adder.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,12 @@ func (s *PrototypesAdder) Run(context map[string]interface{}) error {
4848
}
4949

5050
firstFunctionLine := context[constants.CTX_LINE_WHERE_TO_INSERT_PROTOTYPES].(int)
51-
if firstFunctionOutsideOfSource(firstFunctionLine, sourceRows) {
51+
if isFirstFunctionOutsideOfSource(firstFunctionLine, sourceRows) {
5252
return nil
5353
}
5454

55-
firstFunctionChar := len(strings.Join(sourceRows[:firstFunctionLine+context[constants.CTX_LINE_OFFSET].(int)-1], "\n")) + 1
55+
insertionLine := firstFunctionLine + context[constants.CTX_LINE_OFFSET].(int) - 1
56+
firstFunctionChar := len(strings.Join(sourceRows[:insertionLine], "\n")) + 1
5657
prototypeSection := composePrototypeSection(firstFunctionLine, context[constants.CTX_PROTOTYPES].([]*types.Prototype))
5758
context[constants.CTX_PROTOTYPE_SECTION] = prototypeSection
5859
source = source[:firstFunctionChar] + prototypeSection + source[firstFunctionChar:]
@@ -96,6 +97,6 @@ func signatureContainsaDefaultArg(proto *types.Prototype) bool {
9697
return strings.Contains(proto.Prototype, "=")
9798
}
9899

99-
func firstFunctionOutsideOfSource(firstFunctionLine int, sourceRows []string) bool {
100+
func isFirstFunctionOutsideOfSource(firstFunctionLine int, sourceRows []string) bool {
100101
return firstFunctionLine > len(sourceRows)-1
101102
}

0 commit comments

Comments
 (0)