remove allocations from _next_composite
				
					
				
			This commit is contained in:
		
							parent
							
								
									0748b30593
								
							
						
					
					
						commit
						e3df6e523e
					
				@ -47,15 +47,30 @@ enum EvalTree<'a> {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
type Oet<'a> = Option<EvalTree<'a>>;
 | 
					type Oet<'a> = Option<EvalTree<'a>>;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct Temp;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					impl Atom for Temp {
 | 
				
			||||||
 | 
					    fn next<'t>(self: Box<Self>) -> Oet<'t>
 | 
				
			||||||
 | 
					    where
 | 
				
			||||||
 | 
					        Self: 't,
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        unreachable!()
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl<'a> EvalTree<'a> {
 | 
					impl<'a> EvalTree<'a> {
 | 
				
			||||||
    fn _next_composite(self, other: Box<Self>) -> Self {
 | 
					    fn _next_composite(mut self: Box<Self>, other: Box<Self>) -> Self {
 | 
				
			||||||
        match self {
 | 
					        match *self {
 | 
				
			||||||
            Self::Atom(f) => match f.next() {
 | 
					            Self::Atom(f) => match f.next() {
 | 
				
			||||||
                Some(newleft) => Self::Composite(Box::new(newleft), other),
 | 
					                Some(newleft) => {
 | 
				
			||||||
 | 
					                    *self = newleft;
 | 
				
			||||||
 | 
					                    Self::Composite(self, other)
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
                None => *other,
 | 
					                None => *other,
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            Self::Composite(etll, etlr) => {
 | 
					            Self::Composite(etll, etlr) => {
 | 
				
			||||||
                Self::Composite(etll, Box::new(Self::Composite(etlr, other)))
 | 
					                *self = Self::Composite(etlr, other);
 | 
				
			||||||
 | 
					                Self::Composite(etll, self)
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user