11use crate :: comment:: { Comment , CommentPosition } ;
22
3- pub type Rows = Vec < Vec < Option < Comment > > > ;
3+ pub type Rows < ' a > = Vec < Vec < Option < & ' a Comment > > > ;
44
5- // TODO(SigureMo): Remove clone in the future
6-
7- pub fn init_rows ( num_types : usize , capacity : usize ) -> Rows {
5+ pub fn init_rows < ' a > ( num_types : usize , capacity : usize ) -> Rows < ' a > {
86 let mut rows: Rows = Vec :: new ( ) ;
97 for _ in 0 ..num_types {
108 let mut type_rows = Vec :: with_capacity ( capacity) ;
@@ -35,8 +33,8 @@ pub fn test_free_rows(
3533 let mut current_row = row;
3634 while current_row < rowmax && ( res as f32 ) < comment. height {
3735 if target_row != rows[ comment_pos_id] [ current_row] {
38- target_row = rows[ comment_pos_id] [ current_row] . clone ( ) ;
39- if let Some ( target_row) = target_row. clone ( ) {
36+ target_row = rows[ comment_pos_id] [ current_row] ;
37+ if let Some ( target_row) = target_row {
4038 if target_row. timeline + duration_still > comment. timeline {
4139 break ;
4240 }
@@ -51,8 +49,8 @@ pub fn test_free_rows(
5149 let mut current_row = row;
5250 while current_row < rowmax && ( res as f32 ) < comment. height {
5351 if target_row != rows[ comment_pos_id] [ current_row] {
54- target_row = rows[ comment_pos_id] [ current_row] . clone ( ) ;
55- if let Some ( target_row) = target_row. clone ( ) {
52+ target_row = rows[ comment_pos_id] [ current_row] ;
53+ if let Some ( target_row) = target_row {
5654 if target_row. timeline > threshold_time
5755 || target_row. timeline
5856 + target_row. width as f64 * duration_marquee
@@ -92,12 +90,12 @@ pub fn find_alternative_row(
9290 res
9391}
9492
95- pub fn mark_comment_row ( rows : & mut Rows , comment : & Comment , row : usize ) {
93+ pub fn mark_comment_row < ' a > ( rows : & mut Rows < ' a > , comment : & ' a Comment , row : usize ) {
9694 let comment_pos_id = comment. pos . clone ( ) as usize ;
9795 for i in row..( row + comment. height . ceil ( ) as usize ) {
9896 if i >= rows[ comment_pos_id] . len ( ) {
9997 break ;
10098 }
101- rows[ comment_pos_id] [ i] = Some ( comment. clone ( ) ) ;
99+ rows[ comment_pos_id] [ i] = Some ( comment) ;
102100 }
103101}
0 commit comments