Optimizations and stuff idk

This commit is contained in:
blank X 2021-01-10 13:17:36 +07:00
parent 1d8fac0bd4
commit 1b9d744414
3 changed files with 12 additions and 12 deletions

2
Cargo.lock generated
View File

@ -188,7 +188,7 @@ checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04"
[[package]] [[package]]
name = "holocal" name = "holocal"
version = "0.1.4" version = "0.1.5"
dependencies = [ dependencies = [
"quick-xml", "quick-xml",
"reqwest", "reqwest",

View File

@ -1,6 +1,6 @@
[package] [package]
name = "holocal" name = "holocal"
version = "0.1.4" version = "0.1.5"
authors = ["blank X <theblankx@protonmail.com>"] authors = ["blank X <theblankx@protonmail.com>"]
edition = "2018" edition = "2018"

View File

@ -82,14 +82,14 @@ fn main() {
loop { loop {
match reader.read_event(&mut buf) { match reader.read_event(&mut buf) {
Ok(Event::Start(ref e)) => { Ok(Event::Start(ref e)) => {
match String::from_utf8(e.name().to_vec()).unwrap().as_str() { match e.name() {
"item" => { b"item" => {
is_inside_item = true; is_inside_item = true;
title = None; title = None;
url = None; url = None;
}, },
"title" => is_inside_title = true, b"title" => is_inside_title = true,
"description" => is_inside_description = true, b"description" => is_inside_description = true,
_ => () _ => ()
}; };
}, },
@ -106,9 +106,9 @@ fn main() {
loop { loop {
match description_reader.read_event(&mut description_buf) { match description_reader.read_event(&mut description_buf) {
Ok(Event::Empty(ref e)) => { Ok(Event::Empty(ref e)) => {
if String::from_utf8(e.name().to_vec()).unwrap().as_str() == "img" { if e.name() == b"img" {
url = Some(e.attributes() url = Some(e.attributes()
.find(|attribute| String::from_utf8(attribute.as_ref().unwrap().key.to_vec()).unwrap().as_str() == "src") .find(|attribute| attribute.as_ref().unwrap().key == b"src")
.unwrap() .unwrap()
.unwrap() .unwrap()
.unescape_and_decode_value(&description_reader) .unescape_and_decode_value(&description_reader)
@ -123,20 +123,20 @@ fn main() {
} }
}, },
Ok(Event::End(ref e)) => { Ok(Event::End(ref e)) => {
match String::from_utf8(e.name().to_vec()).unwrap().as_str() { match e.name() {
"item" => { b"item" => {
is_inside_item = false; is_inside_item = false;
if title.is_some() && url.is_some() { if title.is_some() && url.is_some() {
break; break;
} }
}, },
"description" => { b"description" => {
is_inside_description = false; is_inside_description = false;
if title.is_some() && url.is_some() { if title.is_some() && url.is_some() {
break; break;
} }
}, },
"title" => is_inside_title = false, b"title" => is_inside_title = false,
_ => () _ => ()
}; };
}, },