-
-
Notifications
You must be signed in to change notification settings - Fork 241
Move impure-related string allocation to helper methods #8609
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
src/common/dsc.h
Outdated
{ | ||
return isText(); // TODO: add isJson(); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not look proper to me, as CHAR
is not dynamic-length generally (except inside the impure). IMHO, it should be up to the caller (impure class) to check what string types are stored as variable-length.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By this method I mean that dsc_length of content is not fixed. Now I remembered that there is an array type_lengths
that checks exactly this, so I replace this method with the array
src/jrd/evl.cpp
Outdated
string = value->vlu_string = FB_NEW_RPT(*pool, length) VaryingString(); | ||
string->str_length = length; | ||
} | ||
VaryingString* string = value->getAllocateString(from.dsc_length, *pool); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't it be value->getAllocateString(length, *pool)
?
src/jrd/val.h
Outdated
|
||
template<class T> | ||
VaryingString* getAllocateString(T requeuedLength, MemoryPool& pool) = delete; // Prevent dangerous length shrink | ||
VaryingString* getAllocateString(USHORT requeuedLength, MemoryPool& pool); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd call it just getString()
for simplicity but I'm not going to insist.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getAllocateString is not a name that sounds good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usually pool comes first in parameter list.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed the name to getString
with the pool as the first parameter
src/jrd/val.h
Outdated
VaryingString* getAllocateString(USHORT requeuedLength, MemoryPool& pool); | ||
|
||
void makeImpureDscAddress(MemoryPool& pool); | ||
void allocateTextImpureDscAddress(MemoryPool& pool); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're already inside the impure class, so please simplify the names, e.g. makeDscAddress()
/ setupDynamicDscAddress()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These names are weird and maybe due to it, the methods too.
With current names, I prefer the original code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Names are my weak point. I tried others in the last commit, but it would be nice to get your suggestions.
src/jrd/val.h
Outdated
@@ -221,6 +228,40 @@ inline void impure_value::make_decimal_fixed(const Firebird::Int128 val, const s | |||
this->vlu_desc.dsc_address = reinterpret_cast<UCHAR*>(&this->vlu_misc.vlu_int128); | |||
} | |||
|
|||
inline VaryingString* impure_value::getAllocateString(USHORT requeuedLength, MemoryPool& pool) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest newLength
or just length
instead of requeuedLength
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
This is also a preparation for the JSON Type implementation