
Dear Stefan Althoefer,
In message ghhni0$6dv$1@ger.gmane.org you wrote:
That would be one way to avoid unnecessary tests.
Probably not the most elegant approach, agreed.
There are other options, though.
But your suggested optimizations will only be effective if someone tries to write to "serial#". This is not normally done (attempt can be considered an error).
Can it? What make you think so?
There are lots of boards that come fresh out of production with a virgin environment, where setting "serial#" is a perfectly normal thing, and not an error at all.
If access to any nonprotected environment variables is requested (and speed does matter here) then any of the protected cases must be tested.
Yes, but you can do this in many different ways - more and less efficient ones.
Even you code:
if( "serial#" ) ... else if( "ethaddr" ) ... else if( "eth[0-9]+addr" ) ...
then all the ifs are triggered if you write to "videomode".
Yes, we probably can agree that this is one of the less efficient implementations [I take it as pseudo code, because otherwise all cases would execute the "if" branch.]
Best regards,
Wolfgang Denk