Salome HOME
projects
/
modules
/
smesh.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
imn/auto-reorder_of_nodes_ver2
[modules/smesh.git]
/
src
/
SMDS
/
ObjectPool.hxx
diff --git
a/src/SMDS/ObjectPool.hxx
b/src/SMDS/ObjectPool.hxx
index 261ed6459b574aadcfba86b21aa84bc0a7647b21..7af2283c61a3e34f2132258905a46946e45c1316 100644
(file)
--- a/
src/SMDS/ObjectPool.hxx
+++ b/
src/SMDS/ObjectPool.hxx
@@
-1,9
+1,9
@@
-// Copyright (C) 2010-201
2
CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2010-201
4
CEA/DEN, EDF R&D, OPEN CASCADE
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License
, or (at your option) any later version
.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
@@
-42,9
+42,16
@@
private:
int _nextFree;
int _maxAvail;
int _chunkSize;
int _nextFree;
int _maxAvail;
int _chunkSize;
+ int _maxOccupied;
+ int _nbHoles;
int getNextFree()
{
int getNextFree()
{
+ // Don't iterate on the _freeList if all the "holes"
+ // are filled. Go straight to the last occupied ID + 1
+ if ( _nbHoles == 0 )
+ return std::min(_maxOccupied + 1, _maxAvail);
+
for (int i = _nextFree; i < _maxAvail; i++)
if (_freeList[i] == true)
{
for (int i = _nextFree; i < _maxAvail; i++)
if (_freeList[i] == true)
{
@@
-73,6
+80,8
@@
public:
_chunkSize = nblk;
_nextFree = 0;
_maxAvail = 0;
_chunkSize = nblk;
_nextFree = 0;
_maxAvail = 0;
+ _maxOccupied = 0;
+ _nbHoles = 0;
_chunkList.clear();
_freeList.clear();
}
_chunkList.clear();
_freeList.clear();
}
@@
-103,6
+112,14
@@
public:
_freeList[_nextFree] = false;
obj = _chunkList[chunkId] + rank; // &_chunkList[chunkId][rank];
}
_freeList[_nextFree] = false;
obj = _chunkList[chunkId] + rank; // &_chunkList[chunkId][rank];
}
+ if (_nextFree < _maxOccupied)
+ {
+ _nbHoles-=1;
+ }
+ else
+ {
+ _maxOccupied = _nextFree;
+ }
//obj->init();
return obj;
}
//obj->init();
return obj;
}
@@
-124,6
+141,8
@@
public:
_freeList[toFree] = true;
if (toFree < _nextFree)
_nextFree = toFree;
_freeList[toFree] = true;
if (toFree < _nextFree)
_nextFree = toFree;
+ if (toFree < _maxOccupied)
+ _nbHoles += 1;
//obj->clean();
//checkDelete(i); compactage non fait
break;
//obj->clean();
//checkDelete(i); compactage non fait
break;
@@
-134,6
+153,8
@@
public:
{
_nextFree = 0;
_maxAvail = 0;
{
_nextFree = 0;
_maxAvail = 0;
+ _maxOccupied = 0;
+ _nbHoles = 0;
for (size_t i = 0; i < _chunkList.size(); i++)
delete[] _chunkList[i];
clearVector( _chunkList );
for (size_t i = 0; i < _chunkList.size(); i++)
delete[] _chunkList[i];
clearVector( _chunkList );