// SizeDef is same as Size, on error return default size
439443
func SizeDef(size string, defSize uint64) (s uint64) {
	var err error
	if s, err = Size(size); err != nil {
		return defSize
	}

	return s
}
377247
func SizeOf(arr interface{}) int64 {
	if arr == nil {
		return 0
	}
	switch arr.(type) {
	case []int64:
		return AlignObjectSize(NUM_BYTES_ARRAY_HEADER + NUM_BYTES_LONG*int64(len(arr.([]int64))))
	case []int16:
		return AlignObjectSize(NUM_BYTES_ARRAY_HEADER + NUM_BYTES_SHORT*int64(len(arr.([]int16))))
	case []byte:
		return AlignObjectSize(NUM_BYTES_ARRAY_HEADER + int64(len(arr.([]byte))))
	default:
		if t := reflect.TypeOf(arr); t.Kind() == reflect.Slice {
			var size int64
			v := reflect.ValueOf(arr)
			for i := 0; i < v.Len(); i++ {
				size += v.Index(i).Interface().(Accountable).RamBytesUsed()
			}
			return size
		}
		fmt.Println("Unknown type:", reflect.TypeOf(arr))
		panic("not supported yet")
	}
}
1147376
func Resize(s string, length uint) string {
	n := int(length)
	if len(s) == n {
		return s
	}
	// Pads only when length of the string smaller than len needed
	s = PadRight(s, n, ' ')
	if len(s) > n {
		b := []byte(s)
		var buf bytes.Buffer
		for i := 0; i < n-3; i++ {
			buf.WriteByte(b[i])
		}
		buf.WriteString("...")
		s = buf.String()
	}
	return s
}
460648
func CustomSize(format string, size float64, base float64, _map []string) string {
	size, unit := getSizeAndUnit(size, base, _map)
	return fmt.Sprintf(format, size, unit)
}
1022861
func (c Command) Size() int {
	if c.Payload != nil {
		return c.Payload.Size() + 1
	}
	return 1
}
1173049
func (w *Window) Resize(width, height int) (err error) {
	if err = w.isActionable(); err != nil {
		return
	}
	w.m.Lock()
	w.o.Height = PtrInt(height)
	w.o.Width = PtrInt(width)
	w.m.Unlock()
	_, err = synchronousEvent(w.c, w, w.w, Event{Name: EventNameWindowCmdResize, TargetID: w.id, WindowOptions: &WindowOptions{Height: PtrInt(height), Width: PtrInt(width)}}, EventNameWindowEventResize)
	return
}
1355229
func (p *Parser) parseDimension() (*Dimension, error) {
	re, err := p.parseRegex()
	if err != nil {
		return nil, err
	} else if re != nil {
		return &Dimension{Expr: re}, nil
	}

	// Parse the expression first.
	expr, err := p.ParseExpr()
	if err != nil {
		return nil, err
	}

	// Consume all trailing whitespace.
	p.consumeWhitespace()

	return &Dimension{Expr: expr}, nil
}
426923
func MustCreateRef(ref string) Ref {
	r, err := New(ref)
	if err != nil {
		panic(err)
	}
	return r
}
232379
func (e *TextEdit) SizeHint() image.Point {
	var max int
	lines := strings.Split(e.text.String(), "\n")
	for _, line := range lines {
		if w := stringWidth(line); w > max {
			max = w
		}
	}
	return image.Point{max, e.text.heightForWidth(max)}
}
1163783
func (cm CommentMap) Size() int {
	size := 0
	for _, comments := range cm {
		size += len(comments)
	}

	return size
}
983547
func (resizefs *ResizeFs) Resize(devicePath string, deviceMountPath string) (bool, error) {
	return false, fmt.Errorf("Resize is not supported for this build")
}
610484
func Resize(buf []byte, o Options) ([]byte, error) {
	return resizer(buf, o)
}
745543
func (d Display) Size() Size {
	return Size{Height: *d.o.Size.Height, Width: *d.o.Size.Width}
}
1341936
func (w *Window) WMResize(width, height int) error {
	neww, newh, err := adjustSize(w.X, w.Id, width, height)
	if err != nil {
		return err
	}
	return ewmh.ResizeWindow(w.X, w.Id, neww, newh)
}
1101060
func (d *MapDatastore) GetSize(key Key) (size int, err error) {
	if v, found := d.values[key]; found {
		return len(v), nil
	}
	return -1, ErrNotFound
}
242842
func (s *ReindexService) Size(size int) *ReindexService {
	s.size = &size
	return s
}
232022
func (c *Cache) SizeOf() int {

	c.Lock()
	defer c.Unlock()

	return len(c.data)
}