-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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++] Cleanup ATNDeserializer interface #3326
Conversation
7ee71c5
to
5b3ae26
Compare
@mike-lischke More cleanup/optimization. |
ef8169a
to
87acadb
Compare
Note: most of the methods which are virtual don't need to be that, but the C++ runtime was made to mimic the Java runtime as close as possible. After maturing we can probably now remove some of the |
b11bcba
to
fb23a3c
Compare
In this instance, I think removing virtual is safe. There was no way of overriding the virtual methods and using them with ATNDeserializer as the options are copied by value and not referenced. |
09ddc76
to
52b7eea
Compare
da5e341
to
5c4cccc
Compare
f0b2b67
to
92be1ba
Compare
@parrt Here's a pure C++ patch, ready for merge. |
This change does a few things. First it changes
ATNDeserializer
to cache the well known UUIDs usingstd::call_once
which avoids static initialization issues and after the first call has the overhead of only a single atomic load using acquire semantics. Currently the UUIDs are parsed every invocation of the functions.Secondly it marks a few things as
const
and removes the virtual specifiers onATNDeserializationOptions
. This is currently not useful as ATNDeserializationOptions is copied in ATNDeserialization so inheriting from the class doesn't accompolish much. Additionally this allows us to inline a bunch of functions giving the compiler a better chance at optimizing things away. Additionally it usesstd::call_once
to initialize the default options.Lastly it throws
IllegalStateException
when marked as read only, instead of throwing a raw C string which is a big no-no.Note that static initialization order between compilation units is undefined per the C++ standard. To get around this we use
std::call_once
andstd::unique_ptr
which both have constant initialization.