You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The compiler will then decide whether to move or copy the data depending on whether it can prove that buf.init(s) is the last usage of s or not.
However, there are some problems:
If the compiler decides to copy, then there will be a performance hit. To keep good performance in this case, I believe some sort of buffer-via-pointer is needed, e.g. trick's View or collections' View or Nim's experimental view types.
There are some uses of shallowCopy in the codebase that don't neatly fit the sink pattern, e.g.
in Nim 2.0,
shallowCopy
will be removed. This means every occurrence ofshallowCopy
in the library must be replaced by something else.See: nim-lang/Nim#20017
For simple situations,
sink
may be good enough:e.g.
becomes
The compiler will then decide whether to move or copy the data depending on whether it can prove that
buf.init(s)
is the last usage ofs
or not.However, there are some problems:
If the compiler decides to copy, then there will be a performance hit. To keep good performance in this case, I believe some sort of buffer-via-pointer is needed, e.g. trick's View or collections' View or Nim's experimental view types.
There are some uses of
shallowCopy
in the codebase that don't neatly fit thesink
pattern, e.g.(edit, maybe they can be solved like this?)
The text was updated successfully, but these errors were encountered: