-
Notifications
You must be signed in to change notification settings - Fork 40
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
Swift API fine tuning and initial documentation of reader API #76
Conversation
# Conflicts: # FlatBuffersPerformanceTestDesktop/bench.swift
Yes, I like where it is going! |
One thing. I would rather keep all benchmark code in https://github.com/mzaks/FlatBuffersSwiftPerformanceTest |
Remove the obsolete bench.swift file.
Sorry, that should have been gone, should be fixed now. |
What do you think about dropping the
or
What do you think? |
I think that would be good actually, I can continue polish in that direction? |
…nes, rename source files accordingly. Start dropping get prefix.
Ok, will push through a few other changes, can wait with merge of the PR for a while. |
OK! Ping me when you think PR is ready to be merged. |
@hassila what do you think about renaming |
Just a quick question - why do you want to keep both projects together and not separated? |
I actually want to keep them separated. But they might end up in the same project as dependencies. |
Ok, I think it is ready for review and merge if ok - will take a stab at the builder separately. Should probably wait with codegen changes for a bit though as there may be more iterations... |
"I actually want to keep them separated. But they might end up in the same project as dependencies. Scalar is just such a common name that it could collide and because whole module optimisation user might want to keep it as source and not as module dependency" Ah, I see. Perhaps something could be done with nested types, would need some digging... Otherwise the short term fix with |
I'll do an iteration on the builder too now as part of this PR, so please hold again. WIP. |
Sorry I didn't merge it yet. I first waiting for travis for a while and than I forgot 😳 |
No problems, will ping again when next revision is done. |
data -> makeData according to Swift API guidelines (gives a hint that it is an expensive operation, which is good).
…d" interface throughout. Added additional documentation.
Ok, I think it is ready for your review! |
- parameters: | ||
- value: The value to add to the buffer | ||
*/ | ||
public func append<T : Scalar>(value : T){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically it is a prepend. The buffers are built from back to front. @hassila I leave it up to you, if you want to rename it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, but I would probably argue for that the directionality of the layout is a hidden implementation detail (and probably append would then be easier to read at the call site, as the generated code using the append wouldn't know how the buffer is actually updated?), so I would vote for keeping it as is.
We can probably consider additional documentation on the implementation details separately (which would not be a bad thing either :-) )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or would you prefer insert?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm ... insert
sound more neutral. I think I like it :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_data.storeBytes(of: value, toByteOffset: index + leftCursor, as: T.self) | ||
} | ||
|
||
public func openObject(numOfProperties : Int) throws { | ||
/** | ||
Start an object update sequence |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about update. I guess Start object construction sequence, is a bit more appropriate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
@discardableResult | ||
public func addPropertyOffsetToOpenObject(propertyIndex : Int, offset : Offset) throws -> Int{ | ||
public func append(propertyIndex : Int, offset : Offset) throws -> Int{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also here append
feels wrong. maybe insert(offset:toStartedObjectAt:)
is very long but describes the function in the best possible way I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want to reverse the arguments?
Looking at usage, current proposal:
try! fbb.startObject(numOfProperties: 3)
try! fbb.append(propertyIndex: 0, value: true, defaultValue: false)
try! fbb.append(propertyIndex: 1, offset: sOffset)
let oOffset = try! fbb.endObject()
try! fbb.finish(offset: oOffset, fileIdentifier: nil)
would become:
try! fbb.startObject(numOfProperties: 3)
try! fbb.insert(value: true, defaultValue: false, toStartedObjectAt: 0)
try! fbb.insert(offset: sOffset, toStartedObjectAt: 1)
let oOffset = try! fbb.endObject()
try! fbb.finish(offset: oOffset, fileIdentifier: nil)
Perhaps:
try! fbb.startObject(numOfProperties: 3)
try! fbb.update(value: true, defaultValue: false, toStartedObjectAt: 0)
try! fbb.update(offset: sOffset, toStartedObjectAt: 1)
let oOffset = try! fbb.endObject()
try! fbb.finish(offset: oOffset, fileIdentifier: nil)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update
gives me a feeling that I can exchange values. IMHO insert
is ok, also I find the API reads fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, updated in c306411.
Great job! |
Thanks, I'm sure more can be done, but it is an initial attempt! :) |
Some start on polish for:
#55
#75
for your consideration - if you are ok with the direction, I will spend some more time on it.