[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: branches/work/kdevelop-teamwork/network
From: David Nolden <david.nolden.kde () art-master ! de>
Date: 2006-05-31 23:26:43
Message-ID: 1149118003.387270.9882.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 547148 by zwabel:
little optimization
M +23 -6 message.h
M +2 -0 network.kdevelop
M +1 -0 sharedptr.h
--- branches/work/kdevelop-teamwork/network/message.h #547147:547148
@@ -35,18 +35,36 @@
typedef std::vector<unsigned char> IdList;
private:
IdList idList_;
+ unsigned int fastId_; ///can only be used when the idList has <= 4 entries
+ bool useFastId;
+ void packFastId() {
+ fastId_ = 0;
+ if( idList_.size() > 4 ) {
+ useFastId = false;
+ } else {
+ useFastId = true;
+ int shift = 24;
+ for( IdList::iterator it = idList_.begin(); it != idList_.end(); ++it ) {
+ fastId_ += *it << shift;
+ shift -= 8;
+ }
+ }
+ }
public:
- MessageId( IdList IDs = IdList() ) {
+ MessageId( IdList IDs = IdList() ) : useFastId(false) {
idList_ = IDs;
+ packFastId();
}
- MessageId( InArchive& from ) {
+ MessageId( InArchive& from ): useFastId(false) {
from >> idList_;
+ packFastId();
}
void serialize( OutArchive& target, int version ) const {
target << idList_;
}
bool operator < ( const MessageId& rhs ) const {
+ if( useFastId && rhs.useFastId ) return fastId_ < rhs.fastId_;
int s1 = idList_.size();
int s2 = rhs.idList_.size();
int ms = s2 > s1 ? s1 : s2;
@@ -69,11 +87,13 @@
MessageId& operator += ( unsigned char append ) {
idList_.push_back( append );
+ packFastId();
return *this;
}
MessageId& operator -- () {
if( !idList_.empty() ) idList_.pop_back();
+ packFastId();
return *this;
}
@@ -200,10 +220,7 @@
}
};
- /**This allows multiple differing dispatch-targets(like the server + the thread).
- those should not be derived from each other, since they are identified by using \
dynamic_cast
- This class is designed to be thread-safe as long as no new types are added
- */
+ /**This allows multiple differing dispatch-targets(like the server + the thread). \
*/ template<class DispatchTargetType = NoDispatch, class DispatchTargetType2 = \
NoDispatch > class MessageTypeSet : public MessageTypeSetInterface {
typedef std::map<MessageId, MessageFactoryInterface<DispatchTargetType, \
DispatchTargetType2>* > TypeMap;
--- branches/work/kdevelop-teamwork/network/network.kdevelop #547147:547148
@@ -85,6 +85,8 @@
<references>
<pcs>STL</pcs>
<pcs>Common-C++</pcs>
+ <pcs>g++</pcs>
+ <pcs>Boost-Serialization</pcs>
</references>
<qt>
<used>false</used>
--- branches/work/kdevelop-teamwork/network/sharedptr.h #547147:547148
@@ -23,6 +23,7 @@
+
/**
* Warning: Not thread-safe: use SafeShared for thread-safe reference-counting.
* Reference counting for shared objects. If you derive your object
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic