[libcxx-commits] [PATCH] D58332: Erase-Like Algorithms Should Return size_type (P0646R1)

Zoe Carver via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Apr 4 07:59:04 PDT 2019


zoecarver marked 2 inline comments as done.
zoecarver added inline comments.


================
Comment at: include/forward_list:1535
     iterator __e = end();
+    auto __start_count = _VSTD::distance(begin(), end());
     for (iterator __i = before_begin(); __i.__get_begin()->__next_ != nullptr;)
----------------
mclow.lists wrote:
> This is an expensive operation, it requires traversing the list.
> And you're doing it twice - once at the beginning, and once at the end.
I have updated them all to use unsigned integers. Should be much faster. 


================
Comment at: include/list:2158
+    
+    return _VSTD::distance(__deleted_nodes.begin(), __deleted_nodes.end());
 }
----------------
mclow.lists wrote:
> Just call `__deleted_notes.size()` It has constant complexity.
Good call, thanks. 


Repository:
  rCXX libc++

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58332/new/

https://reviews.llvm.org/D58332





More information about the libcxx-commits mailing list