refactor: apply clippy
parent
92baa3d7e8
commit
1ad21b3e90
|
@ -316,6 +316,7 @@ const BIT_MASK: [u64; 64] = [
|
|||
/// decode_all decodes a slice of bytes into a vector of floats.
|
||||
#[allow(dead_code)]
|
||||
#[allow(clippy::many_single_char_names)]
|
||||
#[allow(clippy::useless_let_if_seq)]
|
||||
pub fn decode_all(src: &[u8], dst: &mut Vec<f64>) -> Result<(), Box<dyn Error>> {
|
||||
if src.len() < 9 {
|
||||
return Ok(());
|
||||
|
|
|
@ -104,13 +104,13 @@ impl PointType {
|
|||
/// cases where this series is already in the database, this parse step can be skipped entirely.
|
||||
/// The measurement is represented as a _m key and field as _f.
|
||||
pub fn index_pairs(key: &str) -> Result<Vec<Pair>, ParseError> {
|
||||
let mut chars = key.chars();
|
||||
let chars = key.chars();
|
||||
let mut pairs = vec![];
|
||||
let mut key = "_m".to_string();
|
||||
let mut value = String::with_capacity(250);
|
||||
let mut reading_key = false;
|
||||
|
||||
while let Some(ch) = chars.next() {
|
||||
for ch in chars {
|
||||
match ch {
|
||||
',' => {
|
||||
reading_key = true;
|
||||
|
@ -175,12 +175,10 @@ impl ResponseError for ParseError {
|
|||
pub fn parse(input: &str) -> Vec<PointType> {
|
||||
let mut points: Vec<PointType> = Vec::with_capacity(10000);
|
||||
let lines = input.lines();
|
||||
|
||||
for line in lines {
|
||||
read_line(line, &mut points)
|
||||
}
|
||||
|
||||
return points;
|
||||
points
|
||||
}
|
||||
|
||||
fn read_line(line: &str, points: &mut Vec<PointType>) {
|
||||
|
@ -237,22 +235,19 @@ fn read_value(
|
|||
) -> bool {
|
||||
let mut value = String::new();
|
||||
|
||||
while let Some(ch) = chars.next() {
|
||||
for ch in chars {
|
||||
match ch {
|
||||
' ' | ',' => {
|
||||
let series = measurement_tags.to_string() + "\t" + &field_name;
|
||||
|
||||
// if the last character of the value is an i then it's an integer, otherwise it's
|
||||
// a float (at least until we support the other data types
|
||||
let point = match value.ends_with("i") {
|
||||
true => {
|
||||
let point = if value.ends_with('i') {
|
||||
let val = value[..value.len() - 1].parse::<i64>().unwrap();
|
||||
PointType::new_i64(series, val, 0)
|
||||
}
|
||||
false => {
|
||||
} else {
|
||||
let val = value.parse::<f64>().unwrap();
|
||||
PointType::new_f64(series, val, 0)
|
||||
}
|
||||
};
|
||||
points.push(point);
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ async fn write(
|
|||
.json(serde_json::json!({ "error": format!("{}", err) })));
|
||||
}
|
||||
|
||||
Ok(HttpResponse::Ok().json({}))
|
||||
Ok(HttpResponse::Ok().json(()))
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
|
|
|
@ -41,10 +41,7 @@ pub fn parse_duration(s: &str) -> Result<RelativeDuration, Error> {
|
|||
}
|
||||
|
||||
let i;
|
||||
let mut start = 0;
|
||||
if s.starts_with("-") {
|
||||
start = 1;
|
||||
}
|
||||
let start = if s.starts_with('-') { 1 } else { 0 };
|
||||
|
||||
match s[start..].chars().position(|c| !c.is_digit(10)) {
|
||||
Some(p) => i = p + start,
|
||||
|
|
Loading…
Reference in New Issue