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_BooleanArrayDriver.ixx>
|
||||
#include <TDataStd_BooleanArray.hxx>
|
||||
#include <TColStd_HArray1OfByte.hxx>
|
||||
#include <NCollection_LocalArray.hxx>
|
||||
#include <XmlObjMgt.hxx>
|
||||
|
||||
IMPLEMENT_DOMSTRING (FirstIndexString, "first")
|
||||
@@ -93,9 +94,10 @@ Standard_Boolean XmlMDataStd_BooleanArrayDriver::Paste(const XmlObjMgt_Persisten
|
||||
Handle(TDataStd_BooleanArray) aBooleanArray = Handle(TDataStd_BooleanArray)::DownCast(theTarget);
|
||||
aBooleanArray->Init(aFirstInd, aLastInd);
|
||||
Standard_Integer length = aLastInd - aFirstInd + 1;
|
||||
Handle(TColStd_HArray1OfByte) array = new TColStd_HArray1OfByte(0, length >> 3);
|
||||
Handle(TColStd_HArray1OfByte) hArr = new TColStd_HArray1OfByte(0, length >> 3);
|
||||
TColStd_Array1OfByte& arr = hArr->ChangeArray1();
|
||||
|
||||
Standard_Integer i = 0, upper = array->Upper();
|
||||
Standard_Integer i = 0, upper = arr.Upper();
|
||||
Standard_CString aValueStr = Standard_CString(XmlObjMgt::GetStringValue(anElement).GetString());
|
||||
for (; i <= upper; i++)
|
||||
{
|
||||
@@ -108,9 +110,9 @@ Standard_Boolean XmlMDataStd_BooleanArrayDriver::Paste(const XmlObjMgt_Persisten
|
||||
WriteMessage (aMessageString);
|
||||
return Standard_False;
|
||||
}
|
||||
array->SetValue(i, (Standard_Byte) aValue);
|
||||
arr.SetValue(i, (Standard_Byte) aValue);
|
||||
}
|
||||
aBooleanArray->SetInternalArray(array);
|
||||
aBooleanArray->SetInternalArray(hArr);
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
@@ -127,17 +129,27 @@ void XmlMDataStd_BooleanArrayDriver::Paste(const Handle(TDF_Attribute)& theSourc
|
||||
|
||||
Standard_Integer aL = aBooleanArray->Lower();
|
||||
Standard_Integer anU = aBooleanArray->Upper();
|
||||
TCollection_AsciiString aValueStr;
|
||||
|
||||
theTarget.Element().setAttribute(::FirstIndexString(), aL);
|
||||
theTarget.Element().setAttribute(::LastIndexString(), anU);
|
||||
|
||||
const Handle(TColStd_HArray1OfByte)& array = aBooleanArray->InternalArray();
|
||||
Standard_Integer lower = array->Lower(), i = lower, upper = array->Upper();
|
||||
const Handle(TColStd_HArray1OfByte)& hArr = aBooleanArray->InternalArray();
|
||||
const TColStd_Array1OfByte& arr = hArr->Array1();
|
||||
|
||||
// Allocation of 4 chars for each byte.
|
||||
Standard_Integer iChar = 0;
|
||||
NCollection_LocalArray<Standard_Character> str;
|
||||
if (arr.Length())
|
||||
str.Allocate(4 * arr.Length() + 1);
|
||||
|
||||
// Convert integers - compressed boolean values, to a string.
|
||||
Standard_Integer lower = arr.Lower(), i = lower, upper = arr.Upper();
|
||||
for (; i <= upper; i++)
|
||||
{
|
||||
aValueStr += TCollection_AsciiString((Standard_Integer) array->Value(i));
|
||||
aValueStr += ' ';
|
||||
const Standard_Byte& byte = arr.Value(i);
|
||||
iChar += Sprintf(&(str[iChar]), "%d ", byte);
|
||||
}
|
||||
XmlObjMgt::SetStringValue (theTarget, aValueStr.ToCString(), Standard_True);
|
||||
|
||||
if (arr.Length())
|
||||
XmlObjMgt::SetStringValue (theTarget, (Standard_Character*)str, Standard_True);
|
||||
}
|
||||
|
Reference in New Issue
Block a user