Check for emptiness instead size > 0

From cppcheck:

Checking for 'st' emptiness might be inefficient. Using st.empty()
instead of st.size() can be faster.
st.size() can take linear time but st.empty() is guaranteed to take
constant time.
(cherry picked from commit 1b9f1aee77e47ee5035ee90fb3ba806918addf23)
Use .empty() instead .size()
(cherry picked from commit 87d18f0e01e3ffc396108b0f7fe311eb6178cb20)