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

toSeq should use copyMem when possible #623

Open
timotheecour opened this issue Feb 25, 2021 · 0 comments
Open

toSeq should use copyMem when possible #623

timotheecour opened this issue Feb 25, 2021 · 0 comments

Comments

@timotheecour
Copy link
Owner

timotheecour commented Feb 25, 2021

unless we can guarantee that existing code in toSeq produces the most efficient code in release, we should make toSeq should use copyMem when possible

example

import std/sequtils

type Foo = object
  f0: seq[int]

proc fn(a1: openArray[int])=
  var a2 = [1,2]
  var a3 = @[1,2]
  # var f = Foo(f0: a1) # Error: type mismatch:
  # var f = Foo(f0: a2) # ditto
  # var s = a1 # ditto
  # var f = Foo(f0: a3) # ook
  var s = a1.toSeq # works but via a for-loop (currently); toSeq should use copyMem when possible

fn([1,2])

notes

ideally, copyMem could have a safer wrapper that can be reused (with no performance penalty)
(maybe in strbasics? or rename this module since lots of low-level procs are similar for seq/string?)

links

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