// compileBytes parses the GCSS byte array passed as the s parameter,
// generates a CSS byte array and returns the two channels: the first
// one returns the CSS byte array and the last one returns an error
// when it occurs.
972256
func compileBytes(b []byte) (<-chan []byte, <-chan error) {
	lines := strings.Split(formatLF(string(b)), lf)

	bc := make(chan []byte, len(lines))
	errc := make(chan error)

	go func() {
		ctx := newContext()

		elemc, pErrc := parse(lines)

		for {
			select {
			case elem, ok := <-elemc:
				if !ok {
					close(bc)
					return
				}

				elem.SetContext(ctx)

				switch v := elem.(type) {
				case *mixinDeclaration:
					ctx.mixins[v.name] = v
				case *variable:
					ctx.vars[v.name] = v
				case *atRule, *declaration, *selector:
					bf := new(bytes.Buffer)
					elem.WriteTo(bf)
					bc <- bf.Bytes()
				}
			case err := <-pErrc:
				errc <- err
				return
			}
		}
	}()

	return bc, errc
}
713139
func ParseBytes(str string) (uint64, error) {
	var sep int
	for _, r := range str {
		if !(unicode.IsDigit(r) || r == '.' || r == ',') {
			break
		}

		sep = sep + 1
	}

	var f float64

	if s := strings.Replace(str[:sep], ",", "", -1); len(s) > 0 {
		var err error

		f, err = strconv.ParseFloat(s, 64)
		if err != nil {
			return 0, err
		}
	}

	m, err := ParseByteUnit(str[sep:])
	if err != nil {
		return 0, err
	}

	f = f * float64(m)
	if f >= math.MaxUint64 {
		return 0, errors.New("number of bytes too large")
	}
	return uint64(f), nil
}
1186744
func DecodeBytes(b []byte, val interface{}) error {
	r := bytes.NewReader(b)
	d := NewDecoder(r)
	return d.Decode(val)
}
1175149
func formatBytes(i int64) (result string) {
	switch {
	case i >= TiB:
		result = fmt.Sprintf("%.02f TiB", float64(i)/TiB)
	case i >= GiB:
		result = fmt.Sprintf("%.02f GiB", float64(i)/GiB)
	case i >= MiB:
		result = fmt.Sprintf("%.02f MiB", float64(i)/MiB)
	case i >= KiB:
		result = fmt.Sprintf("%.02f KiB", float64(i)/KiB)
	default:
		result = fmt.Sprintf("%d B", i)
	}
	return
}
1291404
func copyBytes(src []byte) []byte {
	if src == nil {
		return nil
	}
	dst := make([]byte, len(src))
	copy(dst, src)
	return dst
}
1142218
func parseFloatBytes(b []byte, bitSize int) (float64, error) {
	s := unsafeBytesToString(b)
	return strconv.ParseFloat(s, bitSize)
}
171255
func (c *RWI) OutputBytes(data []byte) error {
	return c.WriteFrom(bytes.NewReader(data))
}
172815
func (p *parserMixin) Bytes() (target *units.Base2Bytes) {
	target = new(units.Base2Bytes)
	p.BytesVar(target)
	return
}
118773
func (b *ByteBuf) ReadBytes(n int) (int, []byte, error) {
	data := make([]byte, n)
	n, err := b.Read(data)
	return n, data, err
}
403554
func (be *BinaryEncoder) WriteBytes(value []byte) {
	be.WriteInt32(int32(len(value)))
	copy(be.buffer[be.pos:], value)
	be.pos += len(value)
}
1276657
func Compile(sel string) (Selector, error) {
	p := &parser{s: sel}
	compiled, err := p.parseSelectorGroup()
	if err != nil {
		return nil, err
	}

	if p.i < len(sel) {
		return nil, fmt.Errorf("parsing %q: %d bytes left over", sel, len(sel)-p.i)
	}

	return compiled, nil
}
511868
func bytesToCFData(gobytes []byte) (C.CFDataRef, error) {
	var (
		cptr = (*C.UInt8)(nil)
		clen = C.CFIndex(len(gobytes))
	)

	if len(gobytes) > 0 {
		cptr = (*C.UInt8)(&gobytes[0])
	}

	cdata := C.CFDataCreate(nilCFAllocatorRef, cptr, clen)
	if cdata == nilCFDataRef {
		return nilCFDataRef, errors.New("error creatin cfdata")
	}

	return cdata, nil
}
947128
func (v Version) DataBytes(l Level) int {
	vt := &vtab[v]
	lev := &vt.level[l]
	return vt.bytes - lev.nblock*lev.check
}
210363
func (cfg *TLSConfig) LoadBytes() error {
	var err error
	if cfg.Pem != "" {
		cfg.bytes = []byte(cfg.Pem)
	} else if cfg.Path != "" {
		cfg.bytes, err = ioutil.ReadFile(cfg.Path)
		if err != nil {
			return errors.Wrapf(err, "failed to load pem bytes from path %s", cfg.Path)
		}
	}
	return nil
}
1263888
func (parser *Parser) ParseBytes(contents []byte) error {
	if !parser.initialised {
		if err := parser.init(); err != nil {
			return err
		}
	}

	return parser.rt.run(string(contents))
}
386465
func (c *Chunk) AppendBytes(colIdx int, b []byte) {
	c.columns[colIdx].appendBytes(b)
}
594174
func (se *SizingEncoder) WriteBytes(value []byte) {
	se.WriteInt32(int32(len(value)))
	se.size += len(value)
}