minor optimization

This commit is contained in:
TheAnyKey
2020-06-02 08:03:15 +00:00
parent 1773d2bc14
commit 0ba6470ecf
2 changed files with 28 additions and 7 deletions

27
pdc.sh Executable file
View File

@@ -0,0 +1,27 @@
RUSTPYTHONPATH=Lib
export RUSTPYTHONPATH
ACTIONS=("cargo build" "cargo build --release" "cargo fmt --all" "cargo clippy --all -- -Dwarnings" "cargo test --all" "cargo run --release -- -m test -v" "cd tests" "pytest" "cd ..")
ACT_RES=0
FAILS=()
for act in "${ACTIONS[@]}"; do
$act
if ! [ $? -eq 0 ]; then
ACT_RES=1
FAILS+=("${act}")
fi
done
echo
echo
echo "*********************"
if ! [ $ACT_RES -eq 0 ]; then
echo "PDC failed"
for el in "${FAILS[@]}"; do
echo " Fail ${el}"
done
echo
else
echo "PDC passed"
fi

View File

@@ -114,13 +114,7 @@ impl NameProtocol for Scope {
fn store_cell(&self, vm: &VirtualMachine, name: &str, value: PyObjectRef) {
// find the innermost outer scope that contains the symbol name
if let Some(locals) = self
.locals
.iter()
.rev()
.filter(|l| l.contains_key(name, vm))
.nth(0)
{
if let Some(locals) = self.locals.iter().rev().find(|l| l.contains_key(name, vm)) {
// add to the symbol
locals.set_item(name, value, vm).unwrap();
} else {