Skip to content
This repository was archived by the owner on Jan 25, 2023. It is now read-only.

Improve StringHash Saving - #2570

Open
SirNate0 wants to merge 5 commits into
urho3d:masterfrom
SirNate0:improve-stringhash-saving
Open

SirNate0 wants to merge 5 commits into
urho3d:masterfrom
SirNate0:improve-stringhash-saving

Conversation

@SirNate0

@SirNate0 SirNate0 commented Jan 4, 2020

Copy link
Copy Markdown
Contributor

Since we have the optional ability to compile support for a reverse StringHash lookup, I added the ability to save the string version rather than just the hash for VariantMaps and events in ValueAnimations. Without URHO3D_HASH_DEBUG enabled, reading from these strings is still supported, but saving will simply be done by the hash value instead.

As part of this I also added support for reading a VariantMap from JSON with arbitrary string keys, they simply have to be prefixed with $ to distinguish, for example "BAD" as a string from 0xBAD as a hexadecimal number. I'm open to a different marker besides $, I just like it as I believe it would be allowed in Javascript, it's easy to type, and it would generally be reasonably clear that it's a marker and not part of the string, plus $ looks a lot like S for String.

@ArnisLielturks ArnisLielturks added the улучшение Улучшение существующих вещей label Feb 3, 2020
eventFrameElem.SetFloat("time", eventFrame.time_);
eventFrameElem.SetUInt("eventtype", eventFrame.eventType_.Value());
if (StringHash::GetGlobalStringHashRegister() && !eventFrame.eventType_.Reverse().Empty())
eventFrameElem.SetAttribute("eventname",eventFrame.eventType_.Reverse());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

space missing after ("eventname",

keyFrameVal.Set("time", keyFrame.time_);
JSONValue valueVal;
valueVal.SetVariant(keyFrame.value_);
valueVal.SetVariant(keyFrame.value_,GetContext());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

space missing after (keyFrame.value_,

eventFrameVal.Set("time", eventFrame.time_);
eventFrameVal.Set("eventtype", eventFrame.eventType_.Value());
if (StringHash::GetGlobalStringHashRegister() && !eventFrame.eventType_.Reverse().Empty())
eventFrameVal.Set("eventname",eventFrame.eventType_.Reverse());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

space missing after ("eventname",

eventFrameVal.Set("eventtype", eventFrame.eventType_.Value());
JSONValue eventDataVal;
eventDataVal.SetVariantMap(eventFrame.eventData_);
eventDataVal.SetVariantMap(eventFrame.eventData_,GetContext());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

space missing after (eventFrame.eventData_,

@ArnisLielturks

Copy link
Copy Markdown
Contributor

@SirNate0 So if I understand this correctly, this affects only the reading from JSON and XML files?

@github-actions

github-actions Bot commented Mar 9, 2020

Copy link
Copy Markdown

Marking this stale since there has been no activity for 30 days.
It will be closed if there is no activity for another 15 days.

@github-actions github-actions Bot added the stale label Mar 9, 2020
@weitjong weitjong added backlog and removed stale labels Mar 9, 2020
@eugeneko

eugeneko commented Apr 6, 2020

Copy link
Copy Markdown
Contributor

I think I need to comment on this PR.

I added StringHash reversal functionality for debug purposes only and I actually expect users to disable it before shipping. It's called URHO3D_HASH_DEBUG for that reason.
I never profiled it and I think it slows down some segements of the code.

Therefore, I recommend to treat URHO3D_HASH_DEBUG somewhat like debug C++ build.
Sure, you can do nice debug-only things like logging, but they shouldn't affect functionality.

Having said that, I don't defend hashes in the saved text formats. It's awful.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

backlog улучшение Улучшение существующих вещей

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants