stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Sebor <se...@roguewave.com>
Subject Re: [PATCH] Fix of STDCXX-127
Date Wed, 14 Feb 2007 18:56:51 GMT
Farid Zaripov wrote:
>    Attached is a proposed patch for fix the bug STDCXX-127.
> 
>    ChangeLog:
>    STDCXX-127
>    * deque (swap): Corrected _C_beg._C_node and _C_and._C_node
>    after swap operation for empty container.
> 
> Farid.
> 

Cool. Two comments on this patch (copied below):

Index: deque
===================================================================
--- deque	(revision 507528)
+++ deque	(working copy)
@@ -904,6 +904,30 @@
          _STD::swap (_C_end,       __rhs._C_end);
          _STD::swap (_C_nodes,     __rhs._C_nodes);
          _STD::swap (_C_node_size, __rhs._C_node_size);
+
+        if (   pointer() == _C_beg._C_cur
+            || pointer() == _C_end._C_cur) {
+
+            _RWSTD_ASSERT (   pointer() == _C_beg._C_cur
+                           && pointer() == _C_end._C_cur);


Ft, since you assert that "if one of pointers is so must be
the other" it seems to me that the condition in the if above
could be simplified for efficiency to just (and the same below):

   if (pointer () == _C_beg._C_cur) {
       _RWSTD_ASSERT (pointer () == _C_end._C_cur);
       ...
   }
   else {
       _RWSTD_ASSERT (pointer () != _C_end._C_cur);
   }

Second, since swap is not a trivial function anymore after
this change (it could have been considered non-trivial even
before it) we should outline it and move its definition to
deque.cc.

Do you agree?

Martin

Mime
View raw message