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

[C++ runtime] Improvements of Vocabulary::fromTokenNames #2839

Merged
merged 3 commits into from
Sep 10, 2020

Conversation

IohannRabeson
Copy link
Contributor

This commit doesn't change the behavior. It contains few small improvements to the class Vocabulary:

  • use a reference for the variable tokenName to prevent a useless copy
  • do not to check twice if tokenName is empty
  • removed useless variable firstChar and use std::string::front() when possible
  • use std::string::empty() instead of creating an empty string to compare with
  • use std::string::clear() instead of assigning an empty string to clear a string
  • use defaulted functions when possible

This commit doesn't change the behavior, it contains few small improvements:
- prevent useless copy when creating the variable tokenName
- avoid to check if tokenName is empty twice
- use std::string::empty() instead of creating an empty string to compare with
- use std::string::clear() instead of assigning an empty C string to clear a string
@IohannRabeson IohannRabeson changed the title [C++ runtime] Optimizations of Vocabulary::fromTokenNames [C++ runtime] Improvments of Vocabulary::fromTokenNames Jun 5, 2020
@IohannRabeson IohannRabeson changed the title [C++ runtime] Improvments of Vocabulary::fromTokenNames [C++ runtime] Improvements of Vocabulary::fromTokenNames Jun 5, 2020
@mike-lischke
Copy link
Member

@IohannRabeson Please pull the branch again and fix the conflict.

@parrt After the conflict has been solve this patch can be merged.

@parrt parrt merged commit 49ac9d0 into antlr:master Sep 10, 2020
felixn pushed a commit to felixn/antlr4 that referenced this pull request Oct 4, 2020
felixn pushed a commit to felixn/antlr4 that referenced this pull request Nov 20, 2020
@parrt parrt added this to the 4.9 milestone Nov 24, 2020
felixn pushed a commit to felixn/antlr4 that referenced this pull request Nov 25, 2020
felixn pushed a commit to felixn/antlr4 that referenced this pull request Nov 27, 2020
felixn pushed a commit to felixn/antlr4 that referenced this pull request Nov 30, 2020
felixn pushed a commit to felixn/antlr4 that referenced this pull request Dec 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants