lasselukkari / aWOT

Arduino web server library.
MIT License
283 stars 41 forks source link

Suggestion: Do not allocate a buffer if a closed client is passed to Process #127

Closed EmperorArthur closed 3 years ago

EmperorArthur commented 3 years ago

Hello,

I was looking at pull #125 (I added a note there), and noticed a potential optimization. If myApp.process(client) is called with a closed client, the urlBuffer is allocated, then the writeBuffer is allocated, then the check if client is closed is called. This means that the heap pointer jumps quite a bit in normal operation.

It might be better to just copy and paste this code as first thing in all the versions of Application::process(...)

if (!client) {
    return;
  }

PS: I am changing employers, so am no longer getting paid to ask for nice features / make suggestions. I just like the library and your work on it. It also means I lost access to the $300 Arduino based PLC I was using to test this code with.

lasselukkari commented 3 years ago

Thanks for the suggestions. They have been very valuable for me. It's the first time in 7 years I get meaningful feedback and ideas. I hope the new job will be interesting and they have other nice toys to play with.