mirror of
https://github.com/mangosfour/server.git
synced 2025-12-15 01:37:00 +00:00
[10982] Optimize memory usage of Field class used in DB code. Should also slightly speedup server startup time.
Signed-off-by: Ambal <pogrebniak@gala.net>
This commit is contained in:
parent
f56ae22ed9
commit
b89e531fee
3 changed files with 11 additions and 53 deletions
|
|
@ -34,11 +34,10 @@ class Field
|
|||
DB_TYPE_BOOL = 0x04
|
||||
};
|
||||
|
||||
Field();
|
||||
Field(Field &f);
|
||||
Field(const char *value, enum DataTypes type);
|
||||
Field() : mValue(NULL), mType(DB_TYPE_UNKNOWN) {}
|
||||
Field(const char *value, enum DataTypes type) : mType(type) { mValue = const_cast<char * >(value); }
|
||||
|
||||
~Field();
|
||||
~Field() {}
|
||||
|
||||
enum DataTypes GetType() const { return mType; }
|
||||
bool IsNULL() const { return mValue == NULL; }
|
||||
|
|
@ -68,10 +67,14 @@ class Field
|
|||
}
|
||||
|
||||
void SetType(enum DataTypes type) { mType = type; }
|
||||
|
||||
void SetValue(const char *value);
|
||||
//no need for memory allocations to store resultset field strings
|
||||
//all we need is to cache pointers returned by different DBMS APIs
|
||||
void SetValue(const char *value) { mValue = const_cast<char * >(value); };
|
||||
|
||||
private:
|
||||
Field(Field &f);
|
||||
Field& operator=(const Field& );
|
||||
|
||||
char *mValue;
|
||||
enum DataTypes mType;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue