Skip to content

Commit 759bf22

Browse files
Aayush Kapoorfacebook-github-bot
Aayush Kapoor
authored andcommitted
Updating Comparator for StyleResource::Value and Constructor for StyleResource::Value::Span
Summary: Based on [this comment](https://www.internalfb.com/diff/D75489851?dst_version_fbid=24072947958975860&transaction_fbid=1947206336118573) in D75489851, simplifying the comparator for [StyleResource::Value](https://www.internalfb.com/code/fbsource/[0c35e0fd0ac6c64a9431a4caa5f0be21ccb1dd51]/fbandroid/native/redex/libredex/RedexResources.h?lines=145) since `std::vector` will do a [deep comparison](https://en.cppreference.com/w/cpp/container/vector/operator_cmp.html). Also, added a constructor to StyleResource::Value::Span. Reviewed By: wsanville Differential Revision: D75540675 fbshipit-source-id: 04654ee377b1c82c24d649b06503f8b1a8fed009
1 parent 4386726 commit 759bf22

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

libredex/RedexResources.h

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ UnorderedSet<std::string> parse_keep_xml_file(const std::string& xml_file_path);
144144
struct StyleResource {
145145
struct Value {
146146
struct Span {
147+
Span(std::string tag, uint32_t first_char, uint32_t last_char)
148+
: tag(std::move(tag)), first_char(first_char), last_char(last_char) {}
147149
std::string tag;
148150
uint32_t first_char;
149151
uint32_t last_char;
@@ -175,19 +177,7 @@ struct StyleResource {
175177
if (value_string != other.value_string) {
176178
return false;
177179
}
178-
if (styled_string != other.styled_string) {
179-
return false;
180-
}
181-
182-
if (styled_string.size() != other.styled_string.size()) {
183-
return false;
184-
}
185-
if (!std::equal(styled_string.begin(),
186-
styled_string.end(),
187-
other.styled_string.begin())) {
188-
return false;
189-
}
190-
return true;
180+
return styled_string == other.styled_string;
191181
}
192182

193183
private:

0 commit comments

Comments
 (0)