mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-30 09:36:15 +02:00
* Simplification: registerSubstitutes -> registerSubstitute. We no
longer need the former since there we no longer have the substitutes-rev table (which triggered a O(n^2) cost in updating them).
This commit is contained in:
parent
a9340fa672
commit
2a2756b856
4 changed files with 12 additions and 24 deletions
|
@ -887,7 +887,6 @@ bool DerivationGoal::prepareBuild()
|
||||||
/* Add the relevant output closures of the input derivation
|
/* Add the relevant output closures of the input derivation
|
||||||
`*i' as input paths. Only add the closures of output paths
|
`*i' as input paths. Only add the closures of output paths
|
||||||
that are specified as inputs. */
|
that are specified as inputs. */
|
||||||
/* !!! is `*i' present? */
|
|
||||||
assert(isValidPath(i->first));
|
assert(isValidPath(i->first));
|
||||||
Derivation inDrv = derivationFromPath(i->first);
|
Derivation inDrv = derivationFromPath(i->first);
|
||||||
for (StringSet::iterator j = i->second.begin();
|
for (StringSet::iterator j = i->second.begin();
|
||||||
|
|
|
@ -331,26 +331,19 @@ static void writeSubstitutes(const Transaction & txn,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void registerSubstitutes(const Transaction & txn,
|
void registerSubstitute(const Transaction & txn,
|
||||||
const SubstitutePairs & subPairs)
|
const Path & srcPath, const Substitute & sub)
|
||||||
{
|
{
|
||||||
for (SubstitutePairs::const_iterator i = subPairs.begin();
|
assertStorePath(srcPath);
|
||||||
i != subPairs.end(); ++i)
|
|
||||||
{
|
|
||||||
const Path & srcPath(i->first);
|
|
||||||
const Substitute & sub(i->second);
|
|
||||||
|
|
||||||
assertStorePath(srcPath);
|
Substitutes subs = readSubstitutes(txn, srcPath);
|
||||||
|
|
||||||
Substitutes subs = readSubstitutes(txn, srcPath);
|
/* New substitutes take precedence over old ones. If the
|
||||||
|
substitute is already present, it's moved to the front. */
|
||||||
|
remove(subs.begin(), subs.end(), sub);
|
||||||
|
subs.push_front(sub);
|
||||||
|
|
||||||
/* New substitutes take precedence over old ones. If the
|
writeSubstitutes(txn, srcPath, subs);
|
||||||
substitute is already present, it's moved to the front. */
|
|
||||||
remove(subs.begin(), subs.end(), sub);
|
|
||||||
subs.push_front(sub);
|
|
||||||
|
|
||||||
writeSubstitutes(txn, srcPath, subs);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -41,9 +41,8 @@ void createStoreTransaction(Transaction & txn);
|
||||||
void copyPath(const Path & src, const Path & dst);
|
void copyPath(const Path & src, const Path & dst);
|
||||||
|
|
||||||
/* Register a substitute. */
|
/* Register a substitute. */
|
||||||
typedef list<pair<Path, Substitute> > SubstitutePairs;
|
void registerSubstitute(const Transaction & txn,
|
||||||
void registerSubstitutes(const Transaction & txn,
|
const Path & srcPath, const Substitute & sub);
|
||||||
const SubstitutePairs & subPairs);
|
|
||||||
|
|
||||||
/* Return the substitutes for the given path. */
|
/* Return the substitutes for the given path. */
|
||||||
Substitutes querySubstitutes(const Path & srcPath);
|
Substitutes querySubstitutes(const Path & srcPath);
|
||||||
|
|
|
@ -170,7 +170,6 @@ static void opSubstitute(Strings opFlags, Strings opArgs)
|
||||||
if (!opArgs.empty())
|
if (!opArgs.empty())
|
||||||
throw UsageError("no arguments expected");
|
throw UsageError("no arguments expected");
|
||||||
|
|
||||||
SubstitutePairs subPairs;
|
|
||||||
Transaction txn;
|
Transaction txn;
|
||||||
createStoreTransaction(txn);
|
createStoreTransaction(txn);
|
||||||
|
|
||||||
|
@ -196,12 +195,10 @@ static void opSubstitute(Strings opFlags, Strings opArgs)
|
||||||
references.insert(s);
|
references.insert(s);
|
||||||
}
|
}
|
||||||
if (!cin || cin.eof()) throw Error("missing input");
|
if (!cin || cin.eof()) throw Error("missing input");
|
||||||
subPairs.push_back(pair<Path, Substitute>(srcPath, sub));
|
registerSubstitute(txn, srcPath, sub);
|
||||||
setReferences(txn, srcPath, references);
|
setReferences(txn, srcPath, references);
|
||||||
}
|
}
|
||||||
|
|
||||||
registerSubstitutes(txn, subPairs);
|
|
||||||
|
|
||||||
txn.commit();
|
txn.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue