tempesta-tech / tempesta

All-in-one solution for high performance web content delivery and advanced protection against DDoS and web attacks
https://tempesta-tech.com/
GNU General Public License v2.0
621 stars 103 forks source link

Use src->len directly for copy length in tfw_strcpy() (#2245) #2247

Closed ai-tmpst closed 1 month ago

ai-tmpst commented 1 month ago

There was used 'min(src->len, dst->len)' to determine the number of bytes to copy. However, this check is redundant because the condition 'if (unlikely(src->len > dst->len))' above already ensures that 'src->len' will not exceed 'dst->len'.

This patch simplifies the memcpy operation by using 'src->len' directly as the copy length, making the code more straightforward and slightly more efficient.