Rosen Penev wrote:
The emptiness of a container should be checked using the empty() method
instead of the size() method. It is not guaranteed that size() is a
constant-time function, and it is generally more efficient and also shows
clearer intent to use empty(). Furthermore some containers may implement
the empty() method but not implement the size() method. Using empty()
whenever possible makes it easier to switch to another container in the
future.

For vectors and strings (what ddrescue uses) empty() is defined as 'size() == 0'. So nothing is gained with this change.

Also an automatic replace leaves negations where they are not needed. For example

-      if( c == '\n' ) { if( command.size() ) break; else continue; }
+      if( c == '\n' ) { if( !command.empty() ) break; else continue; }

can be written as

+      if( c == '\n' ) { if( command.empty() ) continue; else break; }

_______________________________________________
Bug-ddrescue mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-ddrescue

Reply via email to