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

@@ -21,6 +21,7 @@
#include <XmlMDataStd_IntegerArrayDriver.ixx>
#include <TDataStd_IntegerArray.hxx>
#include <NCollection_LocalArray.hxx>
#include <XmlObjMgt.hxx>
#include <XmlMDataStd.hxx>
@@ -154,21 +155,36 @@ void XmlMDataStd_IntegerArrayDriver::Paste
{
Handle(TDataStd_IntegerArray) anIntArray =
Handle(TDataStd_IntegerArray)::DownCast(theSource);
const Handle(TColStd_HArray1OfInteger)& hIntArray = anIntArray->Array();
const TColStd_Array1OfInteger& intArray = hIntArray->Array1();
Standard_Integer aL = intArray.Lower(), anU = intArray.Upper();
Standard_Integer aL = anIntArray->Lower(), anU = anIntArray->Upper();
TCollection_AsciiString aValueStr;
if (aL != 1) theTarget.Element().setAttribute (::FirstIndexString(), aL);
if (aL != 1)
theTarget.Element().setAttribute(::FirstIndexString(), aL);
theTarget.Element().setAttribute(::LastIndexString(), anU);
theTarget.Element().setAttribute(::IsDeltaOn(), anIntArray->GetDelta());
// Allocation of 12 chars for each integer including the space.
// An example: -2 147 483 648
Standard_Integer iChar = 0;
NCollection_LocalArray<Standard_Character> str;
if (intArray.Length())
str.Allocate(12 * intArray.Length() + 1);
Standard_Integer i = aL;
while (1) {
aValueStr += TCollection_AsciiString(anIntArray->Value(i));
if (i >= anU) break;
aValueStr += ' ';
while (1)
{
const Standard_Integer& intValue = intArray.Value(i);
iChar += Sprintf(&(str[iChar]), "%d ", intValue);
if (i >= anU)
break;
++i;
}
// No occurrence of '&', '<' and other irregular XML characters
XmlObjMgt::SetStringValue (theTarget, aValueStr.ToCString(), Standard_True);
if (intArray.Length())
{
// No occurrence of '&', '<' and other irregular XML characters
str[iChar - 1] = '\0';
XmlObjMgt::SetStringValue (theTarget, (Standard_Character*)str, Standard_True);
}
}