1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

0023850: TDataStd_ByteArray is too slow on storage on disk

Optimization of a byte-array for XML persistence (binary persistence is ok).
A possible bug is corrected (size of an array is extended a little).
Same improvement for storage of a TDataStd_TreeNode.
Improvement of speed of storage of several Ocaf attributes in XML file format.
Also, format of storage of a double value is extended to keep 17 digits after a decimal point (it was used only 15 digits before).
Several draw-commands are added to manipulate the basic Ocaf attributes:
BooleanArray
BooleanList
IntegerList
RealList
A test-script for OCAF document successfully saved and opened from disk in XML file format.
+ 1 is added to keep '\0'
Removed several spaces in source files.
PLib_LocalArray is renamed to NCollection_LocalArray and became a template. It is used as a local array for Standard_Character in XML OCAF drivers, and as a local array of Standard_Real in PLib package.
Small correction of test case for this fix
This commit is contained in:
vro
2013-05-23 12:09:09 +04:00
parent 5a77460e4a
commit f7b4312f04
19 changed files with 739 additions and 132 deletions

View File

@@ -0,0 +1,83 @@
// Created on: 2009-09-23
// Copyright (c) 2009-2012 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
// except in compliance with the License. Please obtain a copy of the License
// at http://www.opencascade.org and read it completely before using this file.
//
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
//
// The Original Code and all software distributed under the License is
// distributed on an "AS IS" basis, without warranty of any kind, and the
// Initial Developer hereby disclaims all such warranties, including without
// limitation, any warranties of merchantability, fitness for a particular
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
#ifndef _NCollection_LocalArray_HeaderFile
#define _NCollection_LocalArray_HeaderFile
#include <Standard.hxx>
#include <Standard_TypeDef.hxx>
//! Auxiliary class optimizing creation of array buffer
//! (using stack allocation for small arrays).
template<class theItem> class NCollection_LocalArray
{
public:
// 1K * sizeof (theItem)
static const size_t MAX_ARRAY_SIZE = 1024;
NCollection_LocalArray (const size_t theSize)
: myPtr (myBuffer)
{
Allocate(theSize);
}
NCollection_LocalArray ()
: myPtr (myBuffer) {}
virtual ~NCollection_LocalArray()
{
Deallocate();
}
void Allocate (const size_t theSize)
{
Deallocate();
if (theSize > MAX_ARRAY_SIZE)
myPtr = (theItem*)Standard::Allocate (theSize * sizeof(theItem));
else
myPtr = myBuffer;
}
operator theItem*() const
{
return myPtr;
}
private:
NCollection_LocalArray (const NCollection_LocalArray& );
NCollection_LocalArray& operator= (const NCollection_LocalArray& );
protected:
void Deallocate()
{
if (myPtr != myBuffer)
Standard::Free (*(Standard_Address*)&myPtr);
}
protected:
theItem myBuffer[MAX_ARRAY_SIZE];
theItem* myPtr;
};
#endif // _NCollection_LocalArray_HeaderFile