[Python-checkins] python/dist/src/Lib heapq.py,1.12,1.13

gvanrossum@users.sourceforge.net gvanrossum@users.sourceforge.net
Wed, 07 Aug 2002 11:58:13 -0700


Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv7748

Modified Files:
	heapq.py 
Log Message:
Simplify heapreplace() -- there's no need for an explicit test for
empty heap, since heap[0] raises the appropriate IndexError already.


Index: heapq.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/heapq.py,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** heapq.py	3 Aug 2002 19:20:16 -0000	1.12
--- heapq.py	7 Aug 2002 18:58:11 -0000	1.13
***************
*** 151,161 ****
      this routine.
      """
! 
!     if heap:
!         returnitem = heap[0]
!         heap[0] = item
!         _siftup(heap, 0)
!         return returnitem
!     heap.pop()  # raise IndexError
  
  def heapify(x):
--- 151,158 ----
      this routine.
      """
!     returnitem = heap[0]    # raises appropriate IndexError if heap is empty
!     heap[0] = item
!     _siftup(heap, 0)
!     return returnitem
  
  def heapify(x):