Skip to content
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

Fixes #493 and #490 #1807

Merged
merged 5 commits into from
Mar 11, 2015
Merged

Fixes #493 and #490 #1807

merged 5 commits into from
Mar 11, 2015

Conversation

flx5
Copy link
Contributor

@flx5 flx5 commented Mar 11, 2015

I hope this should fix the referenced issues properly?

(Tested only on Windows; Linux to be done)

@madmaxoft
Copy link
Member

Thanks for this, finally someone who can understand the Lua bindings a bit and can help with good code! :)

I do have some concerns about the code, I'll comment on it in a moment.

{
cLuaState LuaState(tolua_S);
std::string str = (std::string)tolua_tocppstring(LuaState, 1, 0);
std::string delim = (std::string)tolua_tocppstring(LuaState, 2, 0);
Copy link
Member

Choose a reason for hiding this comment

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

We have a nice template function cLuaState::GetStackValues() that is better at doing this - it can handle strings with embedded NULs etc. I'd prefer if you used it instead.

@flx5
Copy link
Contributor Author

flx5 commented Mar 11, 2015

Thanks for the feedback.
The new commit should match the coding conventions :)

madmaxoft added a commit that referenced this pull request Mar 11, 2015
@madmaxoft madmaxoft merged commit 439eb8d into cuberite:master Mar 11, 2015
while ((cutAt = str.find_first_of(delim, Prev)) != str.npos)
{
AString current = str.substr(Prev, cutAt - Prev);
if ((current.at(0) == '"') || (current.at(0) == '\''))
Copy link
Member

Choose a reason for hiding this comment

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

Is std::string::at preferred, as opposed to unchecked [] operators? I understand that since it throws exceptions and no exception handlers exist around here, it provides no benefits whilst negatively impacting speed.

@flx5
Copy link
Contributor Author

flx5 commented Mar 12, 2015

What about std::string::front instead of [0]? (simply to have the same syntax as in src/StringUtils.cpp Line 176.
Should I create another pull request for these enhancements?

@tigerw
Copy link
Member

tigerw commented Mar 12, 2015

If you want, though I wouldn't be surprised if the compiler identified it for optimisation anyway.

NiLSPACE added a commit that referenced this pull request Mar 13, 2015
Performance improvements for #1807
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.

None yet

4 participants