// Duplicates functionality in strconv, but avoids dependency.
8716
func atoi(s string) (x int, err error) {
	q, rem, err := signedLeadingInt(s)
	x = int(q)
	if err != nil || rem != "" {
		return 0, atoiError
	}
	return x, nil
}
996957
func (b *BlockedEvals) GetDuplicates(timeout time.Duration) []*structs.Evaluation {
	var timeoutTimer *time.Timer
	var timeoutCh <-chan time.Time
SCAN:
	b.l.Lock()
	if len(b.duplicates) != 0 {
		dups := b.duplicates
		b.duplicates = nil
		b.l.Unlock()
		return dups
	}

	// Capture chans inside the lock to prevent a race with them getting
	// reset in Flush
	dupCh := b.duplicateCh
	stopCh := b.stopCh
	b.l.Unlock()

	// Create the timer
	if timeoutTimer == nil && timeout != 0 {
		timeoutTimer = time.NewTimer(timeout)
		timeoutCh = timeoutTimer.C
		defer timeoutTimer.Stop()
	}

	select {
	case <-stopCh:
		return nil
	case <-timeoutCh:
		return nil
	case <-dupCh:
		goto SCAN
	}
}
778072
func DuplicateProcessIDs() (pids []int, err error) {
	binary, err := Path()
	if err != nil {
		return nil, fmt.Errorf("Can't get path: %v", err)
	}
	return BinaryDuplicateProcessIDs(binary)
}
49252
func checkDuplicateProfileNames(dp models.DeviceProfile, w http.ResponseWriter) error {
	profiles, err := dbClient.GetAllDeviceProfiles()
	if err != nil {
		http.Error(w, err.Error(), http.StatusServiceUnavailable)
		return err
	}

	for _, p := range profiles {
		if p.Name == dp.Name && p.Id != dp.Id {
			err = errors.New("Duplicate profile name")
			http.Error(w, err.Error(), http.StatusConflict)
			return err
		}
	}

	return nil
}
330970
func StringReverse(s string) string {
	newBytes := make([]byte, len(s))
	copy(newBytes, s)
	b := BytesReverse(newBytes)
	return *(*string)(unsafe.Pointer(&b))
}
425068
func (w *ResponseRecorder) Clone() ResponseWriter {
	wc := &ResponseRecorder{}
	wc.headers = w.headers
	wc.chunks = w.chunks[0:]
	if resW, ok := w.ResponseWriter.(*responseWriter); ok {
		wc.ResponseWriter = &(*resW) // clone it
	} else { // else just copy, may pointer, developer can change its behavior
		wc.ResponseWriter = w.ResponseWriter
	}

	return wc
}
210958
func (r *historyRecord) IsDuplicate(other interface{}) bool {
	rother, ok := other.(*historyRecord)
	if !ok {
		return false
	}
	return r.TabletType == rother.TabletType && r.ServingState == rother.ServingState
}
1363934
func JoinRepeat(s, sep string, count int) string {
	switch count {
	case 0:
		return ""
	case 1:
		return s
	case 2:
		return s + sep + s
	case 3:
		return s + sep + s + sep + s
	}

	n := (len(s)+len(sep))*(count-1) + len(s)
	buf := make([]byte, n)
	bp := copy(buf, s)
	for i := 1; i < count; i++ {
		bp += copy(buf[bp:], sep)
		bp += copy(buf[bp:], s)
	}
	return *(*string)(unsafe.Pointer(&buf))
}
566593
func (surface *Surface) Duplicate() (newSurface *Surface, err error) {
	_newSurface := C.SDL_DuplicateSurface(surface.cptr())
	if _newSurface == nil {
		err = GetError()
		return
	}

	newSurface = (*Surface)(unsafe.Pointer(_newSurface))
	return
}
276419
func (n *node) hasDuplicateSibling(key interface{}) bool {
	if n.parent == nil {
		return false
	}
	for _, sibling := range n.parent.children {
		if sibling == n {
			continue
		}
		if sibling.content.key() == key {
			return true
		}
	}
	return false
}
122869
func (mls MultiLineString) Clone() MultiLineString {
	if mls == nil {
		return nil
	}

	nmls := make(MultiLineString, 0, len(mls))
	for _, ls := range mls {
		nmls = append(nmls, ls.Clone())
	}

	return nmls
}
83457
func (r *ResponseDefinition) Dup() *ResponseDefinition {
	res := ResponseDefinition{
		Name:        r.Name,
		Status:      r.Status,
		Description: r.Description,
		MediaType:   r.MediaType,
		ViewName:    r.ViewName,
	}
	if r.Headers != nil {
		res.Headers = DupAtt(r.Headers)
	}
	return &res
}
332586
func isDuplicate(m map[item]struct{}, name, addr string, port uint16) bool {
	if addr != "" {
		_, ok := m[item{name, 0, addr}]
		if !ok {
			m[item{name, 0, addr}] = struct{}{}
		}
		return ok
	}
	_, ok := m[item{name, port, ""}]
	if !ok {
		m[item{name, port, ""}] = struct{}{}
	}
	return ok
}
108887
func Strconv(value interface{}, kind reflect.Kind) (res interface{}) {
	e := fmt.Errorf("Strconv: can't convert %#v to %s", value, kind)
	s := fmt.Sprint(value)

	switch kind {
	case reflect.Bool:
		res, e = strconv.ParseBool(s)
		if e != nil {
			panic(e)
		}
		return

	case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
		res, e = strconv.ParseInt(s, 10, 64)
		if e != nil {
			panic(e)
		}
		return

	case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
		res, e = strconv.ParseUint(s, 10, 64)
		if e != nil {
			panic(e)
		}
		return

	case reflect.Float32, reflect.Float64:
		res, e = strconv.ParseFloat(s, 64)
		if e != nil {
			panic(e)
		}
		return

	case reflect.String:
		return s
	}

	panic(e)
}
50041
func (m NiceMD) Clone(copiedKeys ...string) NiceMD {
	newMd := NiceMD(metadata.Pairs())
	for k, vv := range m {
		found := false
		if len(copiedKeys) == 0 {
			found = true
		} else {
			for _, allowedKey := range copiedKeys {
				if strings.ToLower(allowedKey) == strings.ToLower(k) {
					found = true
					break
				}
			}
		}
		if !found {
			continue
		}
		newMd[k] = make([]string, len(vv))
		copy(newMd[k], vv)
	}
	return NiceMD(newMd)
}
304426
func Clone(src []byte) []byte {
	clone := make([]byte, len(src))
	copy(clone, src)

	return clone
}
1222149
func deduplicate(s []string) []string {
	encountered := map[string]bool{}
	ret := make([]string, 0)
	for i := range s {
		if encountered[s[i]] {
			continue
		}
		encountered[s[i]] = true
		ret = append(ret, s[i])
	}
	return ret
}