File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -109,13 +109,13 @@ pub fn encode(pt: Point<f64>, code_length: usize) -> String {
109
109
// Latitude 90 needs to be adjusted to be just less, so the returned code
110
110
// can also be decoded.
111
111
if lat > LATITUDE_MAX || ( LATITUDE_MAX - lat) < 1e-10f64 {
112
- lat = lat - compute_latitude_precision ( code_length) ;
112
+ lat -= compute_latitude_precision ( code_length) ;
113
113
}
114
114
115
115
lat += LATITUDE_MAX ;
116
116
lng += LONGITUDE_MAX ;
117
117
118
- let mut code = String :: new ( ) ;
118
+ let mut code = String :: with_capacity ( code_length + 1 ) ;
119
119
let mut digit = 0 ;
120
120
while digit < code_length {
121
121
narrow_region ( digit, & mut lat, & mut lng) ;
@@ -130,8 +130,8 @@ pub fn encode(pt: Point<f64>, code_length: usize) -> String {
130
130
code. push ( CODE_ALPHABET [ 4 * lat_digit + lng_digit] ) ;
131
131
digit += 1 ;
132
132
}
133
- lat = lat - lat_digit as f64 ;
134
- lng = lng - lng_digit as f64 ;
133
+ lat -= lat_digit as f64 ;
134
+ lng -= lng_digit as f64 ;
135
135
if digit == SEPARATOR_POSITION {
136
136
code. push ( SEPARATOR ) ;
137
137
}
You can’t perform that action at this time.
0 commit comments