// Copy returns a deep copy of m.
970050
func (m Map) Copy() Map {
	cpy := make(Map, len(m))
	for k, vs := range m {
		cpy[k] = append([]string(nil), vs...)
	}
	return cpy
}
81454
func (a Args) Copy() Args {
	cpy := Args{}
	for _, t := range a {
		cpy = append(cpy, t.Copy())
	}
	return cpy
}
802118
func (m *Manager) Copy() *Manager {
	sess := m.db.Session.Copy()
	copy := New(m.db.With(sess), m.Cfg)
	// TODO (m0sth8): implement copy through the interface
	m.Permission.Copy(copy.Permission)
	m.Vulndb.Copy(copy.Vulndb)
	return copy
}
676996
func (n *Node) Copy() node.Node {
	links := make([]*node.Link, len(n.links))
	copy(links, n.links)

	raw := make([]byte, len(n.raw))
	copy(raw, n.raw)

	tree := make([]string, len(n.tree))
	copy(tree, n.tree)

	return &Node{
		obj:   copyObj(n.obj),
		links: links,
		raw:   raw,
		tree:  tree,
		cid:   n.cid,
	}
}
366443
func (s *Set) Copy() Interface {
	u := newTS()
	for item := range s.m {
		u.Add(item)
	}
	return u
}
157763
func (s *set) Copy() Interface {
	u := newNonTS()
	for item := range s.m {
		u.Add(item)
	}
	return u
}
1054714
func (c *copier) copy(ctx context.Context, src, target string, overwriteTargetMetadata bool) error {
	select {
	case <-ctx.Done():
		return ctx.Err()
	default:
	}
	fi, err := os.Lstat(src)
	if err != nil {
		return errors.Wrapf(err, "failed to stat %s", src)
	}

	if !fi.IsDir() {
		if err := ensureEmptyFileTarget(target); err != nil {
			return err
		}
	}

	copyFileInfo := true

	switch {
	case fi.IsDir():
		if created, err := c.copyDirectory(ctx, src, target, fi, overwriteTargetMetadata); err != nil {
			return err
		} else if !overwriteTargetMetadata {
			copyFileInfo = created
		}
	case (fi.Mode() & os.ModeType) == 0:
		link, err := getLinkSource(target, fi, c.inodes)
		if err != nil {
			return errors.Wrap(err, "failed to get hardlink")
		}
		if link != "" {
			if err := os.Link(link, target); err != nil {
				return errors.Wrap(err, "failed to create hard link")
			}
		} else if err := copyFile(src, target); err != nil {
			return errors.Wrap(err, "failed to copy files")
		}
	case (fi.Mode() & os.ModeSymlink) == os.ModeSymlink:
		link, err := os.Readlink(src)
		if err != nil {
			return errors.Wrapf(err, "failed to read link: %s", src)
		}
		if err := os.Symlink(link, target); err != nil {
			return errors.Wrapf(err, "failed to create symlink: %s", target)
		}
	case (fi.Mode() & os.ModeDevice) == os.ModeDevice:
		if err := copyDevice(target, fi); err != nil {
			return errors.Wrapf(err, "failed to create device")
		}
	default:
		// TODO: Support pipes and sockets
		return errors.Wrapf(err, "unsupported mode %s", fi.Mode())
	}

	if copyFileInfo {
		if err := c.copyFileInfo(fi, target); err != nil {
			return errors.Wrap(err, "failed to copy file info")
		}

		if err := copyXAttrs(target, src, c.xattrErrorHandler); err != nil {
			return errors.Wrap(err, "failed to copy xattrs")
		}
	}
	return nil
}
1086659
func (c *Config) Copy(cfgs ...*Config) *Config {
	dst := &Config{}
	dst.MergeIn(c)

	for _, cfg := range cfgs {
		dst.MergeIn(cfg)
	}

	return dst
}
177494
func (d *DriverNetwork) Copy() *DriverNetwork {
	if d == nil {
		return nil
	}
	pm := make(map[string]int, len(d.PortMap))
	for k, v := range d.PortMap {
		pm[k] = v
	}
	return &DriverNetwork{
		PortMap:       pm,
		IP:            d.IP,
		AutoAdvertise: d.AutoAdvertise,
	}
}
608317
func (c *VaultConfig) Copy() *VaultConfig {
	if c == nil {
		return nil
	}

	nc := new(VaultConfig)
	*nc = *c
	return nc
}
575385
func (body Body) Copy() Body {
	cpy := make(Body, len(body))
	for i := range body {
		cpy[i] = body[i].Copy()
	}
	return cpy
}
312446
func (opt Option) Copy(p []byte) Option {
	n := copy(p, opt.Name)
	opt.Name = p[:n]
	opt.Parameters, p = opt.Parameters.Copy(p[n:])
	return opt
}
52808
func (e *Error) Copy() error {
	if e == nil {
		return nil
	}
	args := types.Copy(reflect.ValueOf(e.args)).Interface().([]interface{})
	n := e.next.Copy()
	var next *Error
	if n != nil {
		next = n.(*Error)
	}
	return &Error{
		err:       e.err,
		args:      args,
		pkg:       e.pkg,
		file:      e.file,
		line:      e.line,
		debugInfo: e.debugInfo,
		next:      next,
	}
}
608592
func Copy(g Iterator) *Mutable {
	switch g := g.(type) {
	case *Mutable:
		return copyMutable(g)
	case *Immutable:
		return copyImmutable(g)
	}
	n := g.Order()
	h := New(n)
	for v := 0; v < n; v++ {
		g.Visit(v, func(w int, c int64) (skip bool) {
			h.AddCost(v, w, c)
			return
		})
	}
	return h
}
1095676
func (obj *object) Copy() Object {
	cpy, _ := obj.Map(func(k, v *Term) (*Term, *Term, error) {
		return k.Copy(), v.Copy(), nil
	})
	return cpy
}
1037558
func (v *Vault) Copy() *Vault {
	if v == nil {
		return nil
	}

	nv := new(Vault)
	*nv = *v
	return nv
}
74277
func Copy(src PackedIntsReader, srcPos int, dest Mutable, destPos, length, mem int) {
	assert(srcPos+length <= int(src.Size()))
	assert(destPos+length <= int(dest.Size()))
	capacity := int(uint(mem) >> 3)
	if capacity == 0 {
		panic("niy")
	} else if length > 0 {
		// use bulk operations
		if length < capacity {
			capacity = length
		}
		buf := make([]int64, capacity)
		copyWith(src, srcPos, dest, destPos, length, buf)
	}
}