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

Model value type in Schema.Map / Schema.Array as a separate enum #5

Open
rahul-malik opened this issue Feb 15, 2017 · 0 comments
Open

Comments

@rahul-malik
Copy link
Collaborator

From @bkase comment on #3 .

@@ -83,10 +83,15 @@ struct ObjCRootsRenderer {
switch schema {
case .Array(itemType: .none):
return "NSArray *"

  •    case .Array(itemType: .some(let itemType)) where itemType.isObjCPrimitiveType:
    

This is probably not worth changing, but -- if it's possible to represent something as a pure pattern match without guards, it's faster because then the switch can compile into a jump table (I don't know if Swift takes advantage of this optimization though).

The way to do that in this case would be to change the way we parse the JSON schema for the Array and Map cases and change itemType to something like:

enum CollectionElement {
case Unknown
case ObjcClass(Schema)
case Primitive(name: String)
}
instead of what is something like Schema?

And then you can do a deeper pattern match on those cases to avoid the where clause

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant