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

Simplify and remove some code from upb::SymbolTable #77

Merged
merged 5 commits into from
Jan 24, 2017

Conversation

haberman
Copy link
Member

This makes upb::SymbolTable no longer refcounted. It also rips out the code to allow replacement of defs in a SymbolTable; this capability was not useful and was buggy. In the future we'll follow the model of the main protobuf implementation: messages can't be redefined.

We do keep some of the legacy "dup" code around because it's currently used for extensions. However we will eventually want to remove this also and handle extensions in a different way.

This transitions it from shared ownership to unique
ownership.
Also hid the dup() functions.  We can't quite delete them yet
because our current approach for extensions depends on duplicating
defs.
upb_status_seterrf(status, "Symtab already has a def named '%s'",
fullname);
goto err;
}
upb_def_donateref(def, ref_donor, s);
if (!upb_strtable_insert(&addtab, fullname, upb_value_ptr(def)))
goto oom_err;

Choose a reason for hiding this comment

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

in the error condition here it appears it won't undonate the ref of the current def

should you move the ref donation after adding successfully to addtab?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good call, done. One benefit of the direction we're going is that the symtab will have an allocator, and we can use that to inject malloc() failure into all these paths.

@@ -2533,18 +2389,11 @@ static bool symtab_add(upb_symtab *s, upb_def *const*defs, size_t n,
oom_err:

Choose a reason for hiding this comment

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

line 2379 above appears unnecessary now since the symtab should not contain anything with the same name

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

upb_def_donateref(def, ref_donor, s);
if (!upb_strtable_insert(&addtab, fullname, upb_value_ptr(def)))
goto oom_err;
def->came_from_user = true;

Choose a reason for hiding this comment

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

remove this member? it appears unused now

Copy link
Member Author

Choose a reason for hiding this comment

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

It was there for the old way of adding extensions. But I just ripped that out too, because I don't think it was actually being used. So extension support is removed until the new, more proto2-like method is implemented.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.5%) to 72.67% when pulling 629b4ce on haberman:axerefcount into 9a9a109 on google:master.

This means extensions can't be used until we implement
the replacement APIs for accessing extensions from a
symtab.
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.008%) to 73.129% when pulling 693b841 on haberman:axerefcount into 9a9a109 on google:master.

Copy link
Member Author

@haberman haberman left a comment

Choose a reason for hiding this comment

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

PTAL.

@@ -2533,18 +2389,11 @@ static bool symtab_add(upb_symtab *s, upb_def *const*defs, size_t n,
oom_err:
Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.04%) to 73.095% when pulling 512130a on haberman:axerefcount into 9a9a109 on google:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.04%) to 73.095% when pulling 5aa01b4 on haberman:axerefcount into 9a9a109 on google:master.

@haberman haberman merged commit 72ae34c into protocolbuffers:master Jan 24, 2017
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