Exemplo n.º 1
0
func (d *inDomains) removeOldDomains() {
	ids := make([]string, 0, len(d.ids))
	atoms := make([]intern.Atom, 0, len(d.atoms))
	for i, domain := range d.ids {
		cathPath := util.CathPath(domain)
		if util.Exists(cathPath) {
			ids = append(ids, d.ids[i])
			atoms = append(atoms, d.atoms[i])
		}
	}
	d.ids, d.atoms = ids, atoms
}
Exemplo n.º 2
0
func readDomains(fpath string) *inDomains {
	domains := &inDomains{
		intern.NewInterner(),
		make([]string, 0, 2000),
		make([]intern.Atom, 0, 2000),
	}

	scanner := bufio.NewScanner(util.OpenFile(fpath))
	for scanner.Scan() {
		d := strings.Fields(scanner.Text())[0]
		d = stripExt(path.Base(util.CathPath(d)))
		a := domains.in.Atom(d)
		domains.ids = append(domains.ids, d)
		domains.atoms = append(domains.atoms, a)
	}
	util.Assert(scanner.Err())
	return domains
}