-
Notifications
You must be signed in to change notification settings - Fork 566
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(config_compiler): "/" mistaken as path separator in merged map key #192
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -155,17 +155,22 @@ inline static string StripOperator(const string& key, bool adding) { | |
} | ||
|
||
// defined in config_data.cc | ||
bool TraverseCopyOnWrite(an<ConfigItemRef> root, const string& path, | ||
function<bool (an<ConfigItemRef> target)> writer); | ||
an<ConfigItemRef> TypeCheckedCopyOnWrite(an<ConfigItemRef> parent, | ||
const string& key); | ||
an<ConfigItemRef> TraverseCopyOnWrite(an<ConfigItemRef> root, | ||
const string& path); | ||
|
||
static bool EditNode(an<ConfigItemRef> target, | ||
const string& key, | ||
const an<ConfigItem>& value, | ||
bool merge_tree) { | ||
DLOG(INFO) << "EditNode(" << key << "," << merge_tree << ")"; | ||
DLOG(INFO) << "edit node: " << key << ", merge_tree: " << merge_tree; | ||
bool appending = IsAppending(key); | ||
bool merging = IsMerging(key, value, merge_tree); | ||
auto writer = [=](an<ConfigItemRef> target) { | ||
if (!target) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you null-check the result of |
||
return false; | ||
} | ||
if ((appending || merging) && **target) { | ||
DLOG(INFO) << "writer: editing node"; | ||
return !value || | ||
|
@@ -181,7 +186,8 @@ static bool EditNode(an<ConfigItemRef> target, | |
string path = StripOperator(key, appending || merging); | ||
DLOG(INFO) << "appending: " << appending << ", merging: " << merging | ||
<< ", path: " << path; | ||
return TraverseCopyOnWrite(target, path, writer); | ||
auto cow_node = merge_tree ? &TypeCheckedCopyOnWrite : &TraverseCopyOnWrite; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The variable name sounds like a "node" but it's not. Name it using a verb phase, for example "find_target_node"? |
||
return writer(cow_node(target, path)); | ||
} | ||
|
||
bool PatchLiteral::Resolve(ConfigCompiler* compiler) { | ||
|
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.
The name
target
is used for another (argument) variable in lambda, which can refer to a different config node. Better differentiate the name.