Below is the list of changes that have just been committed into a local
5.2 repository of rafal. When rafal does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-06-28 18:26:29+02:00, rafal@quant.(none) +2 -0
WL#3169: Move method definitions inside templates.
Apparently, linker on powermac platform is confused by inline template
methods being defined outside the class.
sql/backup/map.h@stripped, 2007-06-28 18:25:26+02:00, rafal@quant.(none) +110 -149
Move method definitions inside template.
sql/backup/stream.h@stripped, 2007-06-28 18:25:27+02:00, rafal@quant.(none) +149 -205
Move method definitions inside template.
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: rafal
# Host: quant.(none)
# Root: /ext/mysql/bk/backup/alpha
--- 1.1/sql/backup/map.h 2007-06-28 18:26:33 +02:00
+++ 1.2/sql/backup/map.h 2007-06-28 18:26:33 +02:00
@@ -20,21 +20,63 @@
typedef typename K::Key Key;
static const size_t size= K::size;
- Key add(const El&);
- El& operator[](const Key&) const;
- Key find(const El&) const;
- bool occupied(const Key&) const;
- size_t count() const { return m_count; };
+ Key add(const El &e)
+ {
+ Key k= D::hash(e);
+ return find_el(k,e,TRUE);
+ }
+
+ El& operator[](const Key &k) const
+ {
+ if (!occupied(k))
+ return const_cast<El&>(D::null);
+
+ return *(entries[k].el);
+ }
+
+ Key find(const El &e) const
+ {
+ Key k= D::hash(e);
+ return const_cast<Map<D,K>*>(this)->find_el(k,e);
+ }
+
+ bool occupied(const Key &k) const
+ {
+ return K::valid_key(k) && entries[k].el != NULL;
+ }
+
+ size_t count() const
+ { return m_count; }
Map(): m_count(0) {}
+ ~Map() { clear(); }
+
+ void clear()
+ {
+ for (uint i=0; i < size; i++)
+ if (entries[i].el)
+ delete entries[i].el;
+ }
+
#ifdef MAP_DEBUG
- void print();
-#endif
- ~Map() { clear(); }
+ void print()
+ {
+ for(uint i=0 ; i < K::size ; i++ )
+ {
+ node &n= entries[i];
+
+ if( n.el )
+ {
+ printf("entry %02d (%d,%d): ", i, (int)n.bigger, (int)n.smaller );
+ D::print(*n.el);
+ printf("\n");
+ }
+ }
+ }
- void clear();
+#endif
protected:
@@ -55,117 +97,59 @@
uint m_count;
- Key find_el(const Key &, const El &, bool insert= FALSE);
- Key find_free_loc() const;
- void set(const Key&, const El&);
-
-};
-
-
-template<class D, class K>
-bool Map<D,K>::occupied(const Key &k) const
-{
- return K::valid_key(k) && entries[k].el != NULL;
-}
-
-template<class D, class K>
-inline
-typename Map<D,K>::El &
-Map<D,K>::operator[](const Key &k) const
-{
- if (!occupied(k))
- return const_cast<El&>(D::null);
-
- return *(entries[k].el);
-}
-
-template<class D, class K>
-inline
-typename Map<D,K>::Key
-Map<D,K>::add(const El &e)
-{
- Key k= D::hash(e);
- return find_el(k,e,TRUE);
-}
-
-template<class D, class K>
-inline
-typename Map<D,K>::Key
-Map<D,K>::find(const El &e) const
-{
- Key k= D::hash(e);
- return const_cast<Map<D,K>*>(this)->find_el(k,e);
-}
-
-// PRE: k is valid.
-template<class D, class K>
-inline
-typename Map<D,K>::Key
-Map<D,K>::find_el(const Key &k, const El &e, bool insert)
-{
- El *x= entries[k].el;
-
- if (!x)
- if (insert)
- {
- set(k,e);
+ // PRE: k is valid.
+ Key find_el(const Key &k, const El &e, bool insert= FALSE)
+ {
+ El *x= entries[k].el;
+
+ if (!x)
+ if (insert)
+ {
+ set(k,e);
+ return k;
+ }
+ else return K::null;
+
+ int res;
+
+ if ((res= D::cmp(e,*x)) == 0)
return k;
+
+ Key &k1 = res>0 ? entries[k].bigger : entries[k].smaller;
+
+ if (K::valid_key(k1))
+ return find_el(k1,e);
+
+ Key k2;
+ if (K::valid_key(k2= find_free_loc()))
+ {
+ k1= k2;
+ set(k2,e);
}
- else return K::null;
-
- int res;
-
- if ((res= D::cmp(e,*x)) == 0)
- return k;
-
- Key &k1 = res>0 ? entries[k].bigger : entries[k].smaller;
-
- if (K::valid_key(k1))
- return find_el(k1,e);
-
- Key k2;
- if (K::valid_key(k2= find_free_loc()))
- {
- k1= k2;
- set(k2,e);
+
+ return k2;
}
- return k2;
-}
-
-
-template<class D, class K>
-inline
-typename Map<D,K>::Key
-Map<D,K>::find_free_loc() const
-{
- if (m_count >= K::size)
+ Key find_free_loc() const
+ {
+ if (m_count >= K::size)
+ return K::null;
+
+ for (uint k=0; k < size; k++)
+ if (entries[k].el == NULL)
+ return k;
+
return K::null;
+ }
+
+ // PRE k is valid
+ void set(const Key &k, const El &e)
+ {
+ entries[k]= e;
+ m_count++;
+ }
- for (uint k=0; k < size; k++)
- if (entries[k].el == NULL)
- return k;
-
- return K::null;
-}
-
-// PRE k is valid
-template<class D, class K>
-inline
-void Map<D,K>::set(const Key &k, const El &e)
-{
- entries[k]= e;
- m_count++;
-}
-
-template<class D, class K>
-inline
-void Map<D,K>::clear()
-{
- for (uint i=0; i < size; i++)
- if (entries[i].el)
- delete entries[i].el;
-}
+};
// 8 bit keys
@@ -182,46 +166,23 @@
key8(): val(0xFF) {};
key8(unsigned int x) { operator=(x); };
- Key &operator=(unsigned int x);
- private:
-
- unsigned char val;
-};
-
-inline
-key8 &key8::operator=(unsigned int x)
-{
- val= x & 0xFF;
- // simple hashing
- for (int bits= sizeof(unsigned int) ; bits > 8 ; bits-= 8)
- {
- x >>= 8;
- val ^= x &0xFF;
- };
- return *this;
-}
-
-
-#ifdef MAP_DEBUG
-
-template<class D, class K>
-void Map<D,K>::print()
-{
- for(uint i=0 ; i < K::size ; i++ )
+ Key &operator=(unsigned int x)
{
- node &n= entries[i];
-
- if( n.el )
+ val= x & 0xFF;
+ // simple hashing
+ for (int bits= sizeof(unsigned int) ; bits > 8 ; bits-= 8)
{
- printf("entry %02d (%d,%d): ", i, (int)n.bigger, (int)n.smaller );
- D::print(*n.el);
- printf("\n");
- }
+ x >>= 8;
+ val ^= x &0xFF;
+ };
+ return *this;
}
-}
-#endif
+ private:
+
+ unsigned char val;
+};
} // util namespace
--- 1.2/sql/backup/stream.h 2007-06-28 18:26:33 +02:00
+++ 1.3/sql/backup/stream.h 2007-06-28 18:26:33 +02:00
@@ -93,10 +93,70 @@
IStream(SWin &swin): m_win(swin)
{}
- Result readbyte(byte &x);
- Result read2int(uint &x);
- Result read4int(ulong &x);
- Result readint(ulong &x);
+ Result readbyte(byte &x)
+ {
+ Result res;
+
+ if ((res= m_win.set_length(1)) != Result(stream_result::OK))
+ return res;
+
+ x= *m_win.head();
+
+ return m_win.move(1);
+ }
+
+ Result read2int(uint &x)
+ {
+ Result res;
+
+ if ((res= m_win.set_length(2)) != Result(stream_result::OK))
+ return res;
+
+ x= uint2korr(m_win.head());
+
+ return m_win.move(2);
+ }
+
+ Result read4int(ulong &x)
+ {
+ Result res;
+
+ if ((res= m_win.set_length(4)) != Result(stream_result::OK))
+ return res;
+
+ x= uint4korr(m_win.head());
+
+ return m_win.move(4);
+ }
+
+ Result readint(ulong &x)
+ {
+ Result res;
+
+ if ((res= m_win.set_length(1)) != Result(stream_result::OK))
+ return res;
+
+ x= *m_win.head();
+ m_win.move(1);
+
+ switch( x ) {
+ case 251:
+ return Result(stream_result::NIL);
+
+ case 252:
+ uint y;
+ res= read2int(y);
+ x= y;
+ return res;
+
+ case 253:
+ return read4int(x);
+
+ default:
+ return Result(stream_result::OK);
+ }
+ }
+
Result readint(uint &x)
{
ulong y;
@@ -105,7 +165,22 @@
return res;
}
- Result readstr(String &s);
+ Result readstr(String &s)
+ {
+ Result res;
+ uint len;
+
+ if ((res= readint(len)) != Result(stream_result::OK))
+ return res;
+
+ if ((res= m_win.set_length(len)) != Result(stream_result::OK))
+ return res;
+
+ s.free();
+ s.copy((const char*)m_win.head(), len, &::my_charset_bin);
+
+ return m_win.move(len);
+ }
};
@@ -122,215 +197,84 @@
OStream(SWin &swin): m_win(swin)
{}
- Result writebyte(const byte x);
- Result write2int(const int x);
- Result write4int(const ulong x);
- Result writeint(const ulong x);
- Result writestr(const String &s);
- Result writestr(const char *s)
- { return writestr(String(s,table_alias_charset)); }
-
- Result writenil();
-};
-
-template<class SW>
-inline
-typename IStream<SW>::Result
-IStream<SW>::readbyte(byte &x)
-{
- Result res;
-
- if ((res= m_win.set_length(1)) != Result(stream_result::OK))
- return res;
-
- x= *m_win.head();
-
- return m_win.move(1);
-}
-
-template<class SW>
-inline
-typename OStream<SW>::Result
-OStream<SW>::writebyte(const byte x)
-{
- Result res;
-
- if ((res= m_win.set_length(1)) != Result(stream_result::OK))
- return res;
-
- (*m_win.head())= x;
-
- return m_win.move(1);
-}
-
-template<class SW>
-inline
-typename IStream<SW>::Result
-IStream<SW>::read2int(uint &x)
-{
- Result res;
-
- if ((res= m_win.set_length(2)) != Result(stream_result::OK))
- return res;
-
- x= uint2korr(m_win.head());
-
- return m_win.move(2);
-}
-
-template<class SW>
-inline
-typename OStream<SW>::Result
-OStream<SW>::write2int(const int x)
-{
- Result res;
-
- if ((res= m_win.set_length(2)) != Result(stream_result::OK))
- return res;
-
- int2store(m_win.head(),x);
-
- return m_win.move(2);
-}
-
-
-template<class SW>
-inline
-typename IStream<SW>::Result
-IStream<SW>::read4int(ulong &x)
-{
- Result res;
-
- if ((res= m_win.set_length(4)) != Result(stream_result::OK))
- return res;
-
- x= uint4korr(m_win.head());
-
- return m_win.move(4);
-}
-
-template<class SW>
-inline
-typename OStream<SW>::Result
-OStream<SW>::write4int(const ulong x)
-{
- Result res;
-
- if ((res= m_win.set_length(4)) != Result(stream_result::OK))
- return res;
-
- int4store(m_win.head(),x);
-
- return m_win.move(4);
-}
-
-
-// write/read number using variable-length encoding
-
-template<class SW>
-inline
-typename IStream<SW>::Result
-IStream<SW>::readint(ulong &x)
-{
- Result res;
-
- if ((res= m_win.set_length(1)) != Result(stream_result::OK))
- return res;
-
- x= *m_win.head();
- m_win.move(1);
-
- switch( x ) {
- case 251:
- return Result(stream_result::NIL);
-
- case 252:
- uint y;
- res= read2int(y);
- x= y;
- return res;
-
- case 253:
- return read4int(x);
-
- default:
- return Result(stream_result::OK);
+ Result writebyte(const byte x)
+ {
+ Result res;
+
+ if ((res= m_win.set_length(1)) != Result(stream_result::OK))
+ return res;
+
+ (*m_win.head())= x;
+
+ return m_win.move(1);
}
-}
-
-template<class SW>
-inline
-typename OStream<SW>::Result
-OStream<SW>::writeint(const ulong x)
-{
- Result res;
- if ((res= m_win.set_length(1)) != Result(stream_result::OK))
- return res;
-
- if (x < 251)
- return writebyte((byte)x);
-
- if (x < (1UL<<16))
+ Result write2int(const int x)
{
- res= writebyte(252);
- return res == Result(stream_result::OK) ? write2int(x) : res;
+ Result res;
+
+ if ((res= m_win.set_length(2)) != Result(stream_result::OK))
+ return res;
+
+ int2store(m_win.head(),x);
+
+ return m_win.move(2);
}
- res= writebyte(253);
- return res == Result(stream_result::OK) ? write4int(x) : res;
-}
-
-
-// Write/read string using "length coded string" format
-
-template<class SW>
-inline
-typename IStream<SW>::Result
-IStream<SW>::readstr(String &s)
-{
- Result res;
- uint len;
-
- if ((res= readint(len)) != Result(stream_result::OK))
- return res;
-
- if ((res= m_win.set_length(len)) != Result(stream_result::OK))
- return res;
-
- s.free();
- s.copy((const char*)m_win.head(), len, &::my_charset_bin);
-
- return m_win.move(len);
-}
-
-template<class SW>
-inline
-typename OStream<SW>::Result
-OStream<SW>::writestr(const String &s)
-{
- Result res;
- uint len= s.length();
-
- if ((res= writeint(len)) != Result(stream_result::OK))
- return res;
-
- if ((res= m_win.set_length(len)) != Result(stream_result::OK))
- return res;
+ Result write4int(const ulong x)
+ {
+ Result res;
+
+ if ((res= m_win.set_length(4)) != Result(stream_result::OK))
+ return res;
+
+ int4store(m_win.head(),x);
+
+ return m_win.move(4);
+ }
- memcpy(m_win.head(), s.ptr(), len);
+ Result writeint(const ulong x)
+ {
+ Result res;
+
+ if ((res= m_win.set_length(1)) != Result(stream_result::OK))
+ return res;
+
+ if (x < 251)
+ return writebyte((byte)x);
+
+ if (x < (1UL<<16))
+ {
+ res= writebyte(252);
+ return res == Result(stream_result::OK) ? write2int(x) : res;
+ }
+
+ res= writebyte(253);
+ return res == Result(stream_result::OK) ? write4int(x) : res;
+ }
- return m_win.move(len);
-}
+ Result writestr(const String &s)
+ {
+ Result res;
+ uint len= s.length();
+
+ if ((res= writeint(len)) != Result(stream_result::OK))
+ return res;
+
+ if ((res= m_win.set_length(len)) != Result(stream_result::OK))
+ return res;
+
+ memcpy(m_win.head(), s.ptr(), len);
+
+ return m_win.move(len);
+ }
-template<class SW>
-inline
-typename OStream<SW>::Result
-OStream<SW>::writenil()
-{
- return writebyte(251);
-}
+ Result writestr(const char *s)
+ { return writestr(String(s,table_alias_charset)); }
+ Result writenil()
+ { return writebyte(251); }
+};
} // util namespace
| Thread |
|---|
| • bk commit into 5.2 tree (rafal:1.2533) | rsomla | 28 Jun |