-
-
Notifications
You must be signed in to change notification settings - Fork 22k
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
Move CowData
find
, rfind
and count
to Span
#103932
Conversation
0891912
to
147fa5c
Compare
7f2ec4e
to
e77561d
Compare
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.
I really like the core idea, but I'm not sure why we're opting for a separate header/namespace over methods within Span
itself. Everything so far uses Span
as the first argument, and based off the name I imagine that'll be the case for the overwhelming majority of functions, so separating them feels like unnecessary bloat. Even if certain functions don't need to be scoped under Span
, the convention is generally to have accompanying classes/functions within the same file (Variant
being the only real exception thanks to its insane size), so that code should all be in span.h
regardless.
Tbh., I also kind of dislike needing the The reason I was even considering putting them in a separate header was compile times and decoupling. But perhaps that's premature optimization. |
No clue how much compile times would be impacted—that's something I think needs more investigation overall—but decoupling is absolutely premature optimization; |
05b7a40
to
b23512f
Compare
Alright, I don't really disagree so I've just moved the functions to |
CowData
find
, rfind
and count
to new header span_algorithms.h
CowData
find
, rfind
and count
to Span
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.
Looks great!
b23512f
to
b37b0b8
Compare
b37b0b8
to
49e8601
Compare
Thanks! |
The idea of this PR is to establish
span_algorithms.h
, where we can put algorithms that run on spans.There are 3 that are currently defined in
CowData
, which could be better defined onSpan
. In this way, people owning aLocalVector
(or perhaps even something else, like Array) could use e.g.spans::find
to find data in the container without re-implementing the algorithm. This is especially important because the algorithms are optimized for speed, while new implementations probably won't be.In addition, the new implementations are substantially faster (same improvement / reason as #102059).
If we agree to go ahead with this, we can move a lot more functions to the
spans
namespace, to start deduplicatingVector
,LocalVector
andString
code.Helps address godotengine/godot-proposals#5144