8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-24 00:03:03 +01:00

applied fixes, mentioned by Claudio

This commit is contained in:
alexpeshkoff 2004-04-19 13:40:30 +00:00
parent 077861de0b
commit 176041c63e
4 changed files with 27 additions and 20 deletions

View File

@ -133,7 +133,7 @@ public:
memmove(data + index + 1, data + index, sizeof(T) * (count++ - index));
data[index] = item;
}
void insert(int index, Array<T>& L) {
void insert(int index, const Array<T, Storage>& L) {
fb_assert(index >= 0 && index <= count);
ensureCapacity(count + L.count);
memmove(data + index + L.count, data + index, sizeof(T) * (count - index));

View File

@ -47,11 +47,13 @@ namespace Firebird
iterator(ObjectsArray *l, int p) : lst(l), pos(p) { }
public:
iterator() : lst(0), pos(0) { }
/*
iterator& operator=(ObjectsArray& a)
{
lst = a.l;
lst = &a;
pos = 0;
}
*/
iterator& operator++() {++pos; return (*this);}
iterator operator++(int) {iterator tmp = *this; ++pos;
return tmp;}

View File

@ -3,24 +3,25 @@
* MODULE: stack.h
* DESCRIPTION: Stack.
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
* The contents of this file are subject to the Initial
* Developer's Public License Version 1.0 (the "License");
* you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
* http://www.ibphoenix.com/main.nfs?a=ibphoenix&page=ibp_idpl.
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
* Software distributed under the License is distributed AS IS,
* WITHOUT WARRANTY OF ANY KIND, either express or implied.
* See the License for the specific language governing rights
* and limitations under the License.
*
* Stack is implemented as a linked list of vectors.
* This makes implementation of merge and split operations
* enough efficcient for large stacks (used in opt.cpp).
* The Original Code was created by Alexander Peshkoff
* for the Firebird Open Source RDBMS project.
*
* Created by: Alex Peshkov <peshkoff@mail.ru>
* Copyright (c) 2004 Alexander Peshkoff <peshkoff@mail.ru>
* and all contributors signed below.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
* All Rights Reserved.
* Contributor(s): ______________________________________.
*
*/
@ -80,6 +81,7 @@ namespace Firebird {
void split(int elem, Entry* target)
{
fb_assert(elem > 0 && elem < count);
memcpy(target->data, data, elem * sizeof(Object));
target->count += elem;
count -= elem;
@ -126,12 +128,15 @@ namespace Firebird {
return tmp;
}
Stack<Object, Capacity>& operator= (Stack<Object, Capacity>& s) {
private:
Stack<Object, Capacity>& operator= (Stack<Object, Capacity>& s);
public:
void takeOwnership (Stack<Object, Capacity>& s) {
fb_assert(&getPool() == &s.getPool());
delete stk;
stk = s.stk;
s.stk = 0;
return *this;
}
class iterator {
@ -151,7 +156,7 @@ namespace Firebird {
{
fb_assert(stk);
if (--elem <= 0) {
if ((stk = stk->next))
if ((stk = stk->next))
{
elem = stk->getCount();
}

View File

@ -5247,7 +5247,7 @@ static bool gen_sort_merge(thread_db* tdbb, OptimizerBlk* opt, RiverStack& org_r
river1->riv_rsb = gen_boolean(tdbb, opt, river1->riv_rsb, node);
}
set_inactive(opt, river1);
org_rivers = newRivers;
org_rivers.takeOwnership(newRivers);
for (stream_nr = 0, fv = flag_vector;
stream_nr < opt->opt_csb->csb_n_stream; stream_nr++)