// Copyright 2016 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package reflectlite

import (
	
	
	
)

// Swapper returns a function that swaps the elements in the provided
// slice.
//
// Swapper panics if the provided interface is not a slice.
func ( any) func(,  int) {
	 := ValueOf()
	if .Kind() != Slice {
		panic(&ValueError{Method: "Swapper", Kind: .Kind()})
	}
	// Fast path for slices of size 0 and 1. Nothing to swap.
	switch .Len() {
	case 0:
		return func(,  int) { panic("reflect: slice index out of range") }
	case 1:
		return func(,  int) {
			if  != 0 ||  != 0 {
				panic("reflect: slice index out of range")
			}
		}
	}

	 := .Type().Elem().common()
	 := .Size()
	 := .PtrBytes != 0

	// Some common & small cases, without using memmove:
	if  {
		if  == goarch.PtrSize {
			 := *(*[]unsafe.Pointer)(.ptr)
			return func(,  int) { [], [] = [], [] }
		}
		if .Kind() == String {
			 := *(*[]string)(.ptr)
			return func(,  int) { [], [] = [], [] }
		}
	} else {
		switch  {
		case 8:
			 := *(*[]int64)(.ptr)
			return func(,  int) { [], [] = [], [] }
		case 4:
			 := *(*[]int32)(.ptr)
			return func(,  int) { [], [] = [], [] }
		case 2:
			 := *(*[]int16)(.ptr)
			return func(,  int) { [], [] = [], [] }
		case 1:
			 := *(*[]int8)(.ptr)
			return func(,  int) { [], [] = [], [] }
		}
	}

	 := (*unsafeheader.Slice)(.ptr)
	 := unsafe_New() // swap scratch space

	return func(,  int) {
		if uint() >= uint(.Len) || uint() >= uint(.Len) {
			panic("reflect: slice index out of range")
		}
		 := arrayAt(.Data, , , "i < s.Len")
		 := arrayAt(.Data, , , "j < s.Len")
		typedmemmove(, , )
		typedmemmove(, , )
		typedmemmove(, , )
	}
}