-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
all: don't use a pointer receiver for many method calls
This is unnecessary because the values are passed by value in other cases, and can in some cases lead to more (heap or stack) allocation than is necessary.
- Loading branch information
1 parent
83fba1b
commit 5746ccf
Showing
4 changed files
with
22 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5746ccf
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Method func (c *DeviceCharacteristic) EnableNotifications(callback func(buf []byte)) needs pointer receiver, because the channel c.property created when notifications were enabled (i.e. with non-nil callback) isn't saved in the structure after the method returns and is therefore not available when the same method is used to disable notifications (i.e. with nil callback).
5746ccf
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@raifrg not necessarily! See for example how this is done on MacOS:
bluetooth/gap_darwin.go
Lines 87 to 103 in a668e1b