2014-08-27 18:19 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
* include/hbserial.ch
* src/rtl/itemseri.c
+ added HB_SERIALIZE_IGNOREREF flag.
This flag fully disables logic used to detect multireferences to the
same complex (sub)items like arrays or hashes. It increses the speed
of serialization but serialized data does not contain any information
about refences, i.e. aVal[ 1 ] and aVal[ 2 ] in code below:
aSub := { 1, 2, 3 }
aVal := { aSub, aSub }
are serialized as separated arrays. Additionally items with cyclic
references like:
aSub[ 2 ] := aSub
cannot be serialized at all with HB_SERIALIZE_IGNOREREF flag because
it will create infinite serialization loop and crash with out of
memory message.
* src/rtl/itemseri.c
% rewritten algorithm used to detect cyclic and multi references in
serialized items. The original algorithm has very high overhead when
huge arrays were serialized, i.e. serialization of array with 1'000'000
of subarrays needed about 30 minutes on my i5@3.30GHz. Now it needs
less then a second and this time is only a little bit bigger then
used by serialization with HB_SERIALIZE_IGNOREREF flag.
This modification improve performance also in other code using Harbour
serialization mechanism like I18N files, HBNETIO, GTNET, ... when large
arrays or hashes are saved or transmitted.
* include/hbapi.h
* include/hbapicls.h
* src/vm/arrays.c
* src/vm/classes.c
* src/vm/hashes.c
* src/vm/itemapi.c
* replaced algorithm used to detect cyclic and multi references in
array and hash clone operations with new one similar to current
item serial code. The speed improvement for very large arrays is
the same as in case of serialization code.
* src/rtl/gtsln/mousesln.c
! typo in while loop - synced with Viktor's branch
This commit is contained in:
@@ -459,11 +459,17 @@ typedef struct _HB_EXTREF
|
||||
HB_EXTREF_FUNC0 mark;
|
||||
} HB_EXTREF, * PHB_EXTREF;
|
||||
|
||||
typedef struct _HB_NESTED_CLONED
|
||||
typedef struct
|
||||
{
|
||||
void * value;
|
||||
PHB_ITEM pDest;
|
||||
struct _HB_NESTED_CLONED * pNext;
|
||||
} HB_NESTED_REF, * PHB_NESTED_REF;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
HB_SIZE nSize;
|
||||
HB_SIZE nCount;
|
||||
PHB_NESTED_REF pRefs;
|
||||
} HB_NESTED_CLONED, * PHB_NESTED_CLONED;
|
||||
|
||||
#endif /* _HB_API_INTERNAL_ */
|
||||
@@ -862,8 +868,10 @@ extern HB_EXPORT HB_LONGLONG hb_arrayGetNLL( PHB_ITEM pArray, HB_SIZE nIndex );
|
||||
/* internal array API not exported */
|
||||
extern void hb_arrayPushBase( PHB_BASEARRAY pBaseArray );
|
||||
extern void hb_arraySwap( PHB_ITEM pArray1, PHB_ITEM pArray2 );
|
||||
extern void hb_cloneNested( PHB_ITEM pDstItem, PHB_ITEM pSrcItem, PHB_NESTED_CLONED pClonedList );
|
||||
extern void hb_hashCloneBody( PHB_ITEM pHash, PHB_ITEM pDest, PHB_NESTED_CLONED pClonedList );
|
||||
extern void hb_nestedCloneInit( PHB_NESTED_CLONED pClonedList, void * pValue, PHB_ITEM pDest );
|
||||
extern void hb_nestedCloneFree( PHB_NESTED_CLONED pClonedList );
|
||||
extern void hb_nestedCloneDo( PHB_ITEM pDstItem, PHB_ITEM pSrcItem, PHB_NESTED_CLONED pClonedList );
|
||||
extern void hb_hashCloneBody( PHB_ITEM pDest, PHB_ITEM pHash, PHB_NESTED_CLONED pClonedList );
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -100,7 +100,8 @@ extern HB_BOOL hb_objGetVarRef( PHB_ITEM pObject, PHB_SYMB pMessage, PHB_STAC
|
||||
extern HB_BOOL hb_objHasOperator( PHB_ITEM pObject, HB_USHORT uiOperator );
|
||||
extern HB_BOOL hb_objOperatorCall( HB_USHORT uiOperator, PHB_ITEM pResult, PHB_ITEM pObject, PHB_ITEM pMsgArg1, PHB_ITEM pMsgArg2 );
|
||||
extern void hb_objDestructorCall( PHB_ITEM pObject );
|
||||
extern void hb_objCloneTo( PHB_ITEM pDest, PHB_ITEM pSource, PHB_NESTED_CLONED pClonedList );
|
||||
extern PHB_ITEM hb_objCloneTo( PHB_ITEM pDest, PHB_ITEM pObject );
|
||||
extern void hb_objCloneBody( PHB_ITEM pDest, PHB_ITEM pObject, PHB_NESTED_CLONED pClonedList );
|
||||
|
||||
#ifndef HB_NO_PROFILER
|
||||
/* profiler for object management */
|
||||
|
||||
@@ -54,5 +54,6 @@
|
||||
#define HB_SERIALIZE_NUMSIZE 0x01
|
||||
#define HB_SERIALIZE_OBJECTSTRUCT 0x02
|
||||
#define HB_SERIALIZE_COMPRESS 0x04
|
||||
#define HB_SERIALIZE_IGNOREREF 0x08
|
||||
|
||||
#endif /* HB_SERIAL_CH_ */
|
||||
|
||||
Reference in New Issue
Block a user