Template Managment complete #27

Merged
MichaelYick merged 9 commits from dev into master 2023-05-23 01:46:55 +00:00
Collaborator

regarding bbf526f99f I am unsure if i am satisfied with this so i might go back to later and force a reentry with a proper name, tho fundamentally i don't think there is an issue with this solution.

regarding bbf526f99febd4b6e3cfc70242205791e63f15e4 I am unsure if i am satisfied with this so i might go back to later and force a reentry with a proper name, tho fundamentally i don't think there is an issue with this solution.
t_a added 5 commits 2023-05-17 16:47:05 +00:00
t_a added 3 commits 2023-05-19 16:11:29 +00:00
MichaelYick requested changes 2023-05-19 17:24:36 +00:00
src/main.cpp Outdated
@ -659,0 +676,4 @@
crow::mustache::context ctx;
if (Utilities::checkCookieLoginState(configuration, cookieCtx)) {
ctx[MUSTACHE_COOKIE_LOGGED_IN] = true;
string name, content, contactdata, contactinformation, currencypreference, priceupfront, priceondeliver;
Owner

From what I'm seeing, these strings are all associated with each other, and may be better off held in a struct. This might make some of the later lines with all the splitItem.at() comparisons a bit easier to deal with.

From what I'm seeing, these strings are all associated with each other, and may be better off held in a struct. This might make some of the later lines with all the splitItem.at() comparisons a bit easier to deal with.
Author
Collaborator

Yeah a struct in this case is quite a good idea

Yeah a struct in this case is quite a good idea
@ -659,0 +697,4 @@
if (splitItem.at(0) == "templatepriceupfront")
priceupfront = splitItem.at(1);
if (splitItem.at(0) == "templatepriceondeliver")
priceondeliver = splitItem.at(1);
Owner

could save splitItem.at(0)'s as a variable, then just use a switch statement to cut down on the amount of times splitItem.at() is called.

could save splitItem.at(0)'s as a variable, then just use a switch statement to cut down on the amount of times splitItem.at() is called.
Author
Collaborator

True, i am kinda pointlessly using at(), [] would have been more appropriate since it directly access the data, maybe i am misunderstanding something but in c++ switch is not capable of evaluating strings and would require an intermediate step that would introduce unnecessary operations.

And i believe saving splitItem.at(0) as a variable would be unnecessary both due to memory and operations, since splitItem[0] should achieve the same thing without the unnecessary performance loss that at() incurs.

True, i am kinda pointlessly using at(), [] would have been more appropriate since it directly access the data, maybe i am misunderstanding something but in c++ switch is not capable of evaluating strings and would require an intermediate step that would introduce unnecessary operations. And i believe saving splitItem.at(0) as a variable would be unnecessary both due to memory and operations, since splitItem[0] should achieve the same thing without the unnecessary performance loss that at() incurs.
src/main.cpp Outdated
@ -698,0 +825,4 @@
priceupfront = splitItem.at(1);
if (splitItem.at(0) == "templatepriceondeliver")
priceondeliver = splitItem.at(1);
}
Owner

could save splitItem.at(0)'s as a variable, then just use a switch statement to cut down on the amount of times splitItem.at() is called.

Given that pattern has appeared twice, it may be a good idea to just make a function for this. However, this advise is conditional on if it would be easy to do that or not.

could save splitItem.at(0)'s as a variable, then just use a switch statement to cut down on the amount of times splitItem.at() is called. Given that pattern has appeared twice, it may be a good idea to just make a function for this. However, this advise is conditional on if it would be easy to do that or not.
Author
Collaborator

I will be moving it into a separate function partially to minimize the duplication of the parser and partially due to the duplication of hardcoded strings

I will be moving it into a separate function partially to minimize the duplication of the parser and partially due to the duplication of hardcoded strings
t_a added 1 commit 2023-05-22 15:05:49 +00:00
Author
Collaborator

the commit 9e5f0a68ab should address it

the commit 9e5f0a68ab should address it
MichaelYick approved these changes 2023-05-23 01:46:31 +00:00
MichaelYick merged commit 04dc38a944 into master 2023-05-23 01:46:53 +00:00
MichaelYick deleted branch dev 2023-05-23 01:47:13 +00:00
Sign in to join this conversation.
No description provided.