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

cbor field sorting for struct autogen #19

Merged
merged 7 commits into from
Jan 23, 2018
Merged

Conversation

whyrusleeping
Copy link
Collaborator

This is still a WIP, but I think its heading in the right direction

@whyrusleeping whyrusleeping force-pushed the feat/struct-field-sorting branch from 77f18ac to f0e686d Compare December 20, 2017 18:04
@warpfork
Copy link
Member

I think I'm mostly happy with this, but would not get rid of the ability to set key sorter modes per specific map type.

Also, when you rebase, could you be so kind as to do the -s signy thing?

}
return entry
}

const (
StructFieldSort_Default = "default"
Copy link
Member

Choose a reason for hiding this comment

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

Missing a type for the consts, plz.

Maybe this is actually the same type and enum when talking about either maps or structs?

switch mach.cfg.MapMorphism.KeySortMode {

ksm := atlas.KeySortMode_Default
if mach.morphism != nil {
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this branch should ever be reachable. The marshaller always sets it during dispatch.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't think thats true... If i take this out i get panics in tests

case entry.MapMorphism != nil:
row.marshalMachineMapWildcard.cfg = entry
case atl.MapMorphism != nil:
row.marshalMachineMapWildcard.morphism = atl.MapMorphism
Copy link
Member

Choose a reason for hiding this comment

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

This line should revert. If there is an explicit entry in the atlas for this type, we should take it. (People will probably write that and be setting the default at the whole atlas scale at the same time incredibly rarely, but still.)

Signed-off-by: Jeromy <jeromyj@gmail.com>
@whyrusleeping whyrusleeping force-pushed the feat/struct-field-sorting branch from 995fb5e to 3de7e76 Compare January 8, 2018 08:12
@whyrusleeping
Copy link
Collaborator Author

@warpfork Alrighty. Hows that. I even signed the commit off like a good citizen

warpfork and others added 5 commits January 13, 2018 11:39
defaults are now scoped to the atlas.  which is much better.

Signed-off-by: Eric Myhre <hash@exultant.us>
Explicit string-sort vs default are both important.  Since these defns are
valid for both maps and structs, 'default' and 'strings' sort may be distinct.

Signed-off-by: Eric Myhre <hash@exultant.us>
Even if we do have the ability to set global defaults.  Exceptions to that
might be rare, but we have all this infrastructure here already...

Signed-off-by: Eric Myhre <hash@exultant.us>
Prefer to use accessor methods so we're at least that step closer to making
it immutable.

Of course it's not properly immutable, and we sort of give up because golang
is not a terribly powerful language and we've already long admitted in this
project that we'll do unsafe things for performance.
(That said, I also would really like to have some time to invest into
benchmarking some of these details again, possibly with the aim of removing
more pointer faffery.)

Remove a case in a switch that I'm fairly sure didn't belong there -- that
switch as a whole is only hit if you're *got* a specific entry of config,
so a branch in it that considers using the default config is nonsensical.
I'd make that change in a separate commit, but keeping it across this
change to an accessor method would make a mess itself.

Also, atlas building now always sets the default mapMorphism.  So, we
can chase down a bunch of unnecessary/redundant nil pointer checks shortly.

Signed-off-by: Eric Myhre <hash@exultant.us>
Signed-off-by: dignifiedquire <dignifiedquire@gmail.com>
Signed-off-by: Jeromy <jeromyj@gmail.com>
@whyrusleeping whyrusleeping force-pushed the feat/struct-field-sorting branch from f94c73f to 84980a6 Compare January 23, 2018 17:51
@warpfork
Copy link
Member

whoooopwhoops testsss

@warpfork warpfork merged commit 110bb24 into master Jan 23, 2018
@warpfork warpfork deleted the feat/struct-field-sorting branch January 23, 2018 17:58
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