operator== for Directives, skips reparse if equal

This commit is contained in:
Kae 2023-08-31 03:14:48 +10:00
parent 6f7f3800d3
commit 182d3052c5
2 changed files with 30 additions and 0 deletions

View File

@ -62,6 +62,32 @@ Directives::Directives(const char* directives) {
parse(directives);
}
Directives& Directives::operator=(String const& directives) {
if (shared && shared->string == directives)
return *this;
parse(String(directives));
return *this;
}
Directives& Directives::operator=(String&& directives) {
if (shared && shared->string == directives) {
directives.clear();
return *this;
}
parse(move(directives));
return *this;
}
Directives& Directives::operator=(const char* directives) {
if (shared && shared->string.utf8().compare(directives) == 0)
return *this;
parse(directives);
return *this;
}
void Directives::loadOperations() const {
if (!shared)
return;

View File

@ -45,6 +45,10 @@ public:
Directives(String&& directives);
Directives(const char* directives);
Directives& operator=(String const& s);
Directives& operator=(String&& s);
Directives& operator=(const char* s);
void loadOperations() const;
void parse(String&& directives);
String string() const;