fn prune_to(&mut self, new_size: &usize) {
        debug!(
            "prune cost table, current size {}, new size {}",
            self.get_count(),
            new_size
        );

        if *new_size == self.get_count() {
            return;
        }

        if *new_size == 0 {
            self.table.clear();
            self.occurrences.clear();
            return;
        }

        let now = Self::micros_since_epoch();
        let mut sorted_by_weighted_age: Vec<_> = self
            .occurrences
            .iter()
            .map(|(key, (count, timestamp))| {
                let age = now - timestamp;
                let weighted_age = *count as i64 * OCCURRENCES_WEIGHT + -(age as i64);
                (weighted_age, *key)
            })
            .collect();
        sorted_by_weighted_age.sort_by(|x, y| x.0.partial_cmp(&y.0).unwrap());

        for i in sorted_by_weighted_age.iter() {
            self.table.remove(&i.1);
            self.occurrences.remove(&i.1);
            if *new_size == self.get_count() {
                break;
            }
        }
    }
// prune the old programs so the table contains `new_size` of records,
// where `old` is defined as weighted age, which is negatively correlated
// with program's age and
// positively correlated with how frequently the program
// is executed (eg. occurrence),
prune the old programs so the table contains `new_size` of records,
where `old` is defined as weighted age, which is negatively correlated
with program's age and
positively correlated with how frequently the program
is executed .
prune the old programs so the table contains ` new_size ` of records where ` old ` is defined as weighted age which is negatively correlated with program ' s age and positively correlated with how frequently the program is executed .
fn prune_to(&mut self, new_size: &usize) {
        debug!(
            "prune cost table, current size {}, new size {}",
            self.get_count(),
            new_size
        );
        if *new_size == self.get_count() {
            return;
        }
        if *new_size == 0 {
            self.table.clear();
            self.occurrences.clear();
            return;
        }
        let now = Self::micros_since_epoch();
        let mut sorted_by_weighted_age: Vec<_> = self
            .occurrences
            .iter()
            .map(|(key, (count, timestamp))| {
                let age = now - timestamp;
                let weighted_age = *count as i64 * OCCURRENCES_WEIGHT + -(age as i64);
                (weighted_age, *key)
            })
            .collect();
        sorted_by_weighted_age.sort_by(|x, y| x.0.partial_cmp(&y.0).unwrap());
        for i in sorted_by_weighted_age.iter() {
            self.table.remove(&i.1);
            self.occurrences.remove(&i.1);
            if *new_size == self.get_count() {
                break;
            }
        }
    }
fn prune_to ( & mut self , new_size : & usize ) { debug ! ( " " self get_count ( ) new_size ) ; if * new_size == self . get_count ( ) { return ; } if * new_size == 0 { self . table . clear ( ) ; self . occurrences . clear ( ) ; return ; } let now = Self :: micros_since_epoch ( ) ; let mut sorted_by_weighted_age : Vec < _ > = self . occurrences . iter ( ) . map ( | ( key , ( count , timestamp ) ) | { let age = now - timestamp ; let weighted_age = * count as i64 * OCCURRENCES_WEIGHT + - ( age as i64 ) ; ( weighted_age , * key ) } ) . collect ( ) ; sorted_by_weighted_age . sort_by ( | x , y | x . 0 . partial_cmp ( & y . 0 ) . unwrap ( ) ) ; for i in sorted_by_weighted_age . iter ( ) { self . table . remove ( & i . 1 ) ; self . occurrences . remove ( & i . 1 ) ; if * new_size == self . get_count ( ) { break ; } } }
prune the old programs so the table contains `new_size` of records,
where `old` is defined as weighted age, which is negatively correlated
with program's age and
positively correlated with how frequently the program
is executed (eg.
prune the old programs so the table contains ` new_size ` of records where ` old ` is defined as weighted age which is negatively correlated with program ' s age and positively correlated with how frequently the program is executed ( eg .
&mut self
new_size
&usize