Prechádzať zdrojové kódy

2008-01-11 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>

	Added Piece::getFirstMissingBlockIndexWithoutLock() and it is 
called
	from PiecedSegment's ctor.
	Previously Piece::getAllMissingBlockIndexes() is called from
	PiecedSegment() but it is rather expensive since only first 
element is
	used.
	* src/PiecedSegment.cc
	* src/Piece.{h, cc}
Tatsuhiro Tsujikawa 18 rokov pred
rodič
commit
1a4100cbc9
4 zmenil súbory, kde vykonal 17 pridanie a 1 odobranie
  1. 10 0
      ChangeLog
  2. 5 0
      src/Piece.cc
  3. 1 0
      src/Piece.h
  4. 1 1
      src/PiecedSegment.cc

+ 10 - 0
ChangeLog

@@ -1,3 +1,13 @@
+2008-01-11  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
+
+	Added Piece::getFirstMissingBlockIndexWithoutLock() and it is called
+	from PiecedSegment's ctor.
+	Previously Piece::getAllMissingBlockIndexes() is called from
+	PiecedSegment() but it is rather expensive since only first element is
+	used.
+	* src/PiecedSegment.cc
+	* src/Piece.{h, cc}
+
 2008-01-11  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
 
 	Rewritten get*Missing*Index functions. Now no need to allocate memory

+ 5 - 0
src/Piece.cc

@@ -95,6 +95,11 @@ int32_t Piece::getMissingBlockIndex() const {
   return blockIndex;
 }
 
+int32_t Piece::getFirstMissingBlockIndexWithoutLock() const
+{
+  return bitfield->getFirstMissingIndex();
+}
+
 BlockIndexes Piece::getAllMissingBlockIndexes() const {
   return bitfield->getAllMissingIndexes();
 }

+ 1 - 0
src/Piece.h

@@ -86,6 +86,7 @@ public:
 
   int32_t getMissingUnusedBlockIndex() const;
   int32_t getMissingBlockIndex() const;
+  int32_t getFirstMissingBlockIndexWithoutLock() const;
   BlockIndexes getAllMissingBlockIndexes() const;
   void completeBlock(int32_t blockIndex);
   void cancelBlock(int32_t blockIndex);

+ 1 - 1
src/PiecedSegment.cc

@@ -38,7 +38,7 @@
 PiecedSegment::PiecedSegment(int32_t pieceLength, const PieceHandle& piece):
   _pieceLength(pieceLength), _overflowLength(0), _piece(piece)
 {
-  _writtenLength = _piece->getAllMissingBlockIndexes().front()*_piece->getBlockLength();
+  _writtenLength = _piece->getFirstMissingBlockIndexWithoutLock()*_piece->getBlockLength();
 }
 
 PiecedSegment::~PiecedSegment() {}