// parseTreeData parses tree information from the (uncompressed) raw
// data from the tree object.
427477
func parseTreeData(tree *Tree, data []byte) ([]*TreeEntry, error) {
	entries := make([]*TreeEntry, 0, 10)
	l := len(data)
	pos := 0
	for pos < l {
		entry := new(TreeEntry)
		entry.ptree = tree
		step := 6
		switch string(data[pos : pos+step]) {
		case "100644", "100664":
			entry.mode = ENTRY_MODE_BLOB
			entry.Type = OBJECT_BLOB
		case "100755":
			entry.mode = ENTRY_MODE_EXEC
			entry.Type = OBJECT_BLOB
		case "120000":
			entry.mode = ENTRY_MODE_SYMLINK
			entry.Type = OBJECT_BLOB
		case "160000":
			entry.mode = ENTRY_MODE_COMMIT
			entry.Type = OBJECT_COMMIT

			step = 8
		case "040000":
			entry.mode = ENTRY_MODE_TREE
			entry.Type = OBJECT_TREE
		default:
			return nil, fmt.Errorf("unknown type: %v", string(data[pos:pos+step]))
		}
		pos += step + 6 // Skip string type of entry type.

		step = 40
		id, err := NewIDFromString(string(data[pos : pos+step]))
		if err != nil {
			return nil, err
		}
		entry.ID = id
		pos += step + 1 // Skip half of sha1.

		step = bytes.IndexByte(data[pos:], '\n')

		// In case entry name is surrounded by double quotes(it happens only in git-shell).
		if data[pos] == '"' {
			entry.name = string(UnescapeChars(data[pos+1 : pos+step-1]))
		} else {
			entry.name = string(data[pos : pos+step])
		}

		pos += step + 1
		entries = append(entries, entry)
	}
	return entries, nil
}
271508
func (t *Tree) Parse(buf string) (tree *Tree, err error) {
	t.scanner.init(buf)
	t.Root, err = t.parseAny()
	return t, err
}
732353
func (s *GCMMessage) SetData(v map[string]*string) *GCMMessage {
	s.Data = v
	return s
}
306436
func (s *GetProtectionStatusOutput) SetData(v string) *GetProtectionStatusOutput {
	s.Data = &v
	return s
}
497837
func (js *JSONConfig) ParseData(data []byte) (Configer, error) {
	x := &JSONConfigContainer{
		data: make(map[string]interface{}),
	}
	err := json.Unmarshal(data, &x.data)
	if err != nil {
		var wrappingArray []interface{}
		err2 := json.Unmarshal(data, &wrappingArray)
		if err2 != nil {
			return nil, err
		}
		x.data["rootArray"] = wrappingArray
	}
	return x, nil
}
846361
func (client *Client) DecryptData(inData []byte) (data []byte, err error) {
	for _, key := range client.PrivateKeys {
		data, err := rsa.DecryptOAEP(client.Hash, client.Reader, key, inData, nil)

		if err == nil {
			return data, nil
		}
	}

	return nil, errors.New("failed to decrypt data due to no private key matching")
}
537678
func (t *Tree) Parse() error {
	go t.lex.tokenize()
	for {
		n, err := t.parse()
		if err != nil {
			return t.enrichError(err)
		}
		if n == nil {
			break
		}
		t.root.Append(n)
	}
	t.traverse(t.root)
	return nil
}
332635
func (t *Tree) parse(treeSet map[string]*Tree) (next Node) {
	t.Root = t.newList(t.peek().pos)
	for t.peek().typ != itemEOF {
		if t.peek().typ == itemLeftDelim {
			delim := t.next()
			if t.nextNonSpace().typ == itemDefine {
				newT := New("definition") // name will be updated once we know it.
				newT.text = t.text
				newT.ParseName = t.ParseName
				newT.startParse(t.funcs, t.lex)
				newT.parseDefinition(treeSet)
				continue
			}
			t.backup2(delim)
		}
		n := t.textOrAction()
		if n.Type() == nodeEnd {
			t.errorf("unexpected %s", n)
		}
		t.Root.append(n)
	}
	return nil
}
445954
func (tn *TreeNode) SwapChildData(d *ChildData) *ChildData {
	tn.Lock()
	defer tn.Unlock()
	old := tn.childData
	tn.childData = d
	return old
}
1254048
func (tb *KeyStringValueTreeBuilder) Tree() (collections.KeyStringValueTree, error) {
	if !tb.done {
		return nil, errors.New(ErrBuilder, errorMessages, "building is not yet done")
	}
	return tb.tree, nil
}
515586
func (s *Row) SetData(v []*Datum) *Row {
	s.Data = v
	return s
}
26444
func cmdSetTreeCharset(ctx *cli.Context, config utils.ConfigReader) {
	if ctx.Bool("ascii") {
		treeCharset = treeASCII
	} else if !utils.Isatty(os.Stdout) {
		treeCharset = treeSPACE
	} else if config.BoolVal("TREE_ASCII", false) {
		treeCharset = treeASCII
	}
}
362416
func NewTreeSet(layout geom.Layout, compare Compare) *TreeSet {
	return &TreeSet{
		layout:  layout,
		stride:  layout.Stride(),
		compare: compare,
	}
}
227816
func (tc *TreeCache) SetCacheData(cacheData bool) *TreeCache {
	tc.cacheData = cacheData
	return tc
}
201952
func (tc *TreeCache) CurrentData(fullPath string) (*ChildData, error) {
	node, err := tc.findNode(fullPath)
	if err != nil {
		return nil, err
	}
	if node.state.Load() != NodeStateLIVE {
		return nil, ErrNodeNotLive
	}

	return node.ChildData(), nil
}
861123
func (base *Base) SetData(key string, value string) {
	if base.Data == nil {
		base.Data = make(map[string]string)
	}
	base.Data[key] = value
}
664133
func (p *peer) SendNodeData(data [][]byte) error {
	return p2p.Send(p.rw, NodeDataMsg, data)
}