used existing empty place in vector when allocate a new one
This commit is contained in:
parent
bfbe67bc42
commit
55a2bfcc29
|
@ -40,7 +40,14 @@ int HandleTable::createHandle() {
|
|||
file->isOpened = false;
|
||||
|
||||
int existingFilesNum = m_files.size();
|
||||
// TODO when i close a file m_files probably have a open pos , so we can fill this
|
||||
|
||||
for (int index = 0; index < existingFilesNum; index++) {
|
||||
if (m_files.at(index) == nullptr) {
|
||||
m_files[index] = file;
|
||||
return index;
|
||||
}
|
||||
}
|
||||
|
||||
m_files.push_back(file);
|
||||
|
||||
return existingFilesNum - 1;
|
||||
|
|
Loading…
Reference in New Issue