forked from openvswitch/ovs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
smap: New macro SMAP_CONST1 for initializing immutable 1-member smaps.
Reviewing the ovn-controller code I started to notice a common pattern: struct smap ext_ids = SMAP_INITIALIZER(&ext_ids); smap_add(&ext_ids, "ovn-patch-port", network); ovsrec_port_set_external_ids(port, &ext_ids); smap_destroy(&ext_ids); This seemed like a bit too much code for something as simple as initializing an smap with a single key-value pair. This commit allows the code to be reduced to just: const struct smap ids = SMAP_CONST1(&ids, "ovn-patch-port", network); ovsrec_port_set_external_ids(port, &ids); This new form also eliminates multiple memory allocation and free operations, but I doubt that has any real effect on performance; the primary goal here is code readability. Signed-off-by: Ben Pfaff <[email protected]> Acked-by: Russell Bryant <[email protected]>
- Loading branch information
Showing
6 changed files
with
41 additions
and
29 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
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