mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-09-18 14:27:39 +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_RealListDriver.ixx>
|
||||
#include <TDataStd_RealList.hxx>
|
||||
#include <TColStd_ListIteratorOfListOfReal.hxx>
|
||||
#include <NCollection_LocalArray.hxx>
|
||||
#include <XmlObjMgt.hxx>
|
||||
|
||||
IMPLEMENT_DOMSTRING (FirstIndexString, "first")
|
||||
@@ -135,18 +136,19 @@ void XmlMDataStd_RealListDriver::Paste(const Handle(TDF_Attribute)& theSource,
|
||||
Handle(TDataStd_RealList) aRealList = Handle(TDataStd_RealList)::DownCast(theSource);
|
||||
|
||||
Standard_Integer anU = aRealList->Extent();
|
||||
TCollection_AsciiString aValueStr;
|
||||
|
||||
theTarget.Element().setAttribute(::LastIndexString(), anU);
|
||||
if (anU >= 1)
|
||||
{
|
||||
// Allocation of 25 chars for each double value including the space:
|
||||
// An example: -3.1512678732195273e+020
|
||||
Standard_Integer iChar = 0;
|
||||
NCollection_LocalArray<Standard_Character> str(25 * anU + 1);
|
||||
TColStd_ListIteratorOfListOfReal itr(aRealList->List());
|
||||
for (; itr.More(); itr.Next())
|
||||
{
|
||||
aValueStr += TCollection_AsciiString(itr.Value());
|
||||
aValueStr += ' ';
|
||||
const Standard_Real& realValue = itr.Value();
|
||||
iChar += Sprintf(&(str[iChar]), "%.17g ", realValue);
|
||||
}
|
||||
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