瀏覽代碼

HPCC-12085 Avoid malloc/free when updating the buffer callbacks

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
Gavin Halliday 11 年之前
父節點
當前提交
1413ea6c40
共有 3 個文件被更改,包括 24 次插入2 次删除
  1. 2 2
      roxie/roxiemem/roxiemem.cpp
  2. 2 0
      system/jlib/jarray.hpp
  3. 20 0
      system/jlib/jarray.tpp

+ 2 - 2
roxie/roxiemem/roxiemem.cpp

@@ -2302,8 +2302,8 @@ public:
     {
         //Possibly over the top, but calculate information so we can do a round robin at various
         //different levels of priority
-        callbackRanges.kill();
-        nextCallbacks.kill();
+        callbackRanges.clear();
+        nextCallbacks.clear();
         nextCallbacks.append(0);
         unsigned prevPriority = 0;
         ForEachItemIn(i, rowBufferCallbacks)

+ 2 - 0
system/jlib/jarray.hpp

@@ -136,6 +136,7 @@ public:
     CopyArrayOf() { SELF::_init(); }
     ~CopyArrayOf();
     
+    void clear();
     inline PARAM item(aindex_t pos) const;
     PARAM tos(void) const;
     PARAM tos(aindex_t) const;
@@ -160,6 +161,7 @@ public:
     OwningArrayOf() { SELF::_init(); }
     ~OwningArrayOf();
     
+    void clear(bool nodel = false);                  /* Remove all items, don't free array */
     void kill(bool nodel = false);                   /* Remove all items        */
     void pop(bool nodel = false);
     void popn(aindex_t,bool nodel = false);

+ 20 - 0
system/jlib/jarray.tpp

@@ -124,6 +124,12 @@ void BaseArrayOf<MEMBER, PARAM>::sort(CompareFunc cf)
  ************************************************************************/
 
 template <class MEMBER, class PARAM>
+void CopyArrayOf<MEMBER, PARAM>::clear()
+{
+   SELF::used = 0;
+}
+
+template <class MEMBER, class PARAM>
 PARAM CopyArrayOf<MEMBER, PARAM>::item(aindex_t pos) const
 {
    assertex(SELF::isItem(pos)); return Array__Member2Param(((MEMBER *)AllocatorOf<sizeof(MEMBER)>::_head)[pos]);
@@ -219,6 +225,20 @@ bool CopyArrayOf<MEMBER, PARAM>::zap(PARAM sought)
  ************************************************************************/
 
 template <class MEMBER, class PARAM>
+void OwningArrayOf<MEMBER, PARAM>::clear(bool nodestruct)
+{
+    MEMBER * head= (MEMBER *)SELF::_head;
+    aindex_t count = SELF::used;
+
+    SELF::used = 0;
+    if (!nodestruct)
+    {
+       for (aindex_t i=0; i<count; i++)
+          Array__Destroy(head[i]);
+    }
+}
+
+template <class MEMBER, class PARAM>
 void OwningArrayOf<MEMBER, PARAM>::kill(bool nodestruct)
 {
    MEMBER * head= (MEMBER *)SELF::_head;