-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Changed arg, hasArg, header, hasHeader from const char * to String #1560
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
Conversation
Added arg_P hasArg_P and hasHeader_P to be able to test arg from string stored in flash
How do you feel about replacing the two methods (one taking const char* and another one taking PGM_P) with one method taking a String? |
@igrr
|
I mean leave just |
This permet calling these with const char *, String or PGM_P type parameter
Makes sense, glad to know these kind are converted to string :-) |
Thanks! Could you please change |
Yeah, of course, it's done |
the use of String has one "problem", |
Good catch, whatever solution is fine for me, my initial goal was just to be able to call these arg and hasArg with PGM_P flash stored string and I did not find a way to get it working (ie compiling) without using String, but I'm ready to learn because it's making me mad ;-) |
I don't think that extra memory consumption due to Sting use is an issue for this particular use case, since argument names are usually quite short. |
I must admit both have pro/cons, String is simple and by the way I think it's more speed efficient for my case, because if we loop among all args to match name we search (I've got about 30 args) doing some pgm_read_byte (needed to compare) for each char of each args can be slower than a String comp? But may be I'm wrong. |
@igrr yes for this short data its not a big deal, my post where more a general info to only having String as parameter type, for example for sending payload data to a Webserver its not a good idea when you have big data. There are some potential for optimization in our code too, for example using "String &" to avoid unnecessary data duplication in ram. @hallard for the arg loop case the String will perform better then PGM_P and little bit faster then const char* since the String class already know the length of the string and so the first step is the length compare which is faster then only byte by byte. |
Changed arg, hasArg, header, hasHeader from const char * to String
Guys, The code
The code
The .ino
the result
seems PGM_P arguments have problem to be converted to String automatically |
Forgot this one, just my revert back from #1582, code reverted back ;-) |
Added arg_P hasArg_P and hasHeader_P to be able to test arg from string
stored in flash