Skip to content

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Noremos
Copy link
Contributor

@Noremos Noremos commented Jun 18, 2025

This is also a preparation for the JSON Type implementation

src/common/dsc.h Outdated
{
return isText(); // TODO: add isJson();
}

Copy link
Member

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.

Copy link
Contributor Author

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);
Copy link
Member

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);
Copy link
Member

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.

Copy link
Member

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.

Copy link
Member

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.

Copy link
Contributor Author

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);
Copy link
Member

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().

Copy link
Member

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.

Copy link
Contributor Author

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)
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants