mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-04 13:13:25 +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:
@@ -21,6 +21,7 @@
|
||||
#include <XmlMDataStd_IntegerListDriver.ixx>
|
||||
#include <TDataStd_IntegerList.hxx>
|
||||
#include <TColStd_ListIteratorOfListOfInteger.hxx>
|
||||
#include <NCollection_LocalArray.hxx>
|
||||
#include <XmlObjMgt.hxx>
|
||||
|
||||
IMPLEMENT_DOMSTRING (FirstIndexString, "first")
|
||||
@@ -127,18 +128,21 @@ void XmlMDataStd_IntegerListDriver::Paste(const Handle(TDF_Attribute)& theSource
|
||||
Handle(TDataStd_IntegerList) anIntList = Handle(TDataStd_IntegerList)::DownCast(theSource);
|
||||
|
||||
Standard_Integer anU = anIntList->Extent();
|
||||
TCollection_AsciiString aValueStr;
|
||||
|
||||
theTarget.Element().setAttribute(::LastIndexString(), anU);
|
||||
if (anU >= 1)
|
||||
{
|
||||
// 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(12 * anU + 1);
|
||||
TColStd_ListIteratorOfListOfInteger itr(anIntList->List());
|
||||
for (; itr.More(); itr.Next())
|
||||
{
|
||||
aValueStr += TCollection_AsciiString(itr.Value());
|
||||
aValueStr += ' ';
|
||||
const Standard_Integer& intValue = itr.Value();
|
||||
iChar += Sprintf(&(str[iChar]), "%d ", intValue);
|
||||
}
|
||||
|
||||
// No occurrence of '&', '<' and other irregular XML characters
|
||||
XmlObjMgt::SetStringValue (theTarget, (Standard_Character*)str, Standard_True);
|
||||
}
|
||||
// No occurrence of '&', '<' and other irregular XML characters
|
||||
XmlObjMgt::SetStringValue (theTarget, aValueStr.ToCString(), Standard_True);
|
||||
}
|
||||
|
Reference in New Issue
Block a user