-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Always use config pointer for New and Reload
Always use pointer for the Config object for New and Reload methods. This reduces the memory, but needs a bit of care to not modifying the passed configuration within daemon. To avoid that, implement DeepCopy and always copy configuration at the beginning of the New and Reload. Signed-off-by: Yutaro Hayakawa <[email protected]>
- Loading branch information
1 parent
7e01202
commit 79a8feb
Showing
10 changed files
with
100 additions
and
37 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
MAKEFLAGS += --silent | ||
|
||
all: | ||
|
||
deepcopy: | ||
deep-copy -pointer-receiver --type Config --type InterfaceConfig -o zz_generated_deepcopy.go . | ||
|
||
check-deepcopy: | ||
deep-copy -pointer-receiver --type Config --type InterfaceConfig -o zz_generated_deepcopy.go . | ||
git diff --exit-code zz_generated_deepcopy.go || echo "deepcopy is not up to date. Please commit the changes."; git diff zz_generated_deepcopy.go |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// generated by deep-copy -pointer-receiver --type Config --type InterfaceConfig -o zz_generated_deepcopy.go .; DO NOT EDIT. | ||
|
||
package radv | ||
|
||
// DeepCopy generates a deep copy of *Config | ||
func (o *Config) DeepCopy() *Config { | ||
var cp Config = *o | ||
if o.Interfaces != nil { | ||
cp.Interfaces = make([]*InterfaceConfig, len(o.Interfaces)) | ||
copy(cp.Interfaces, o.Interfaces) | ||
for i2 := range o.Interfaces { | ||
if o.Interfaces[i2] != nil { | ||
cp.Interfaces[i2] = o.Interfaces[i2].DeepCopy() | ||
} | ||
} | ||
} | ||
return &cp | ||
} | ||
|
||
// DeepCopy generates a deep copy of *InterfaceConfig | ||
func (o *InterfaceConfig) DeepCopy() *InterfaceConfig { | ||
var cp InterfaceConfig = *o | ||
return &cp | ||
} |