[librsvg: 8/32] Extract function
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 8/32] Extract function
- Date: Fri, 4 Dec 2020 21:11:30 +0000 (UTC)
commit 63cfcbf5d92d8ab7f1a49ab46cf6bea851a1cce8
Author: Federico Mena Quintero <federico gnome org>
Date: Wed Nov 25 12:36:51 2020 -0600
Extract function
src/document.rs | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
---
diff --git a/src/document.rs b/src/document.rs
index 1d47c711..082d46b4 100644
--- a/src/document.rs
+++ b/src/document.rs
@@ -243,20 +243,24 @@ fn load_image(
Ok(surface)
}
-fn image_loading_error_from_cairo(status: cairo::Status, aurl: &AllowedUrl) -> LoadingError {
- let human_readable_url = if aurl.scheme() == "data" {
+fn human_readable_url(aurl: &AllowedUrl) -> &str {
+ if aurl.scheme() == "data" {
// avoid printing a huge data: URL for image data
"data URL"
} else {
aurl.as_ref()
- };
+ }
+}
+
+fn image_loading_error_from_cairo(status: cairo::Status, aurl: &AllowedUrl) -> LoadingError {
+ let url = human_readable_url(aurl);
match status {
cairo::Status::NoMemory => {
- LoadingError::OutOfMemory(format!("loading image: {}", human_readable_url))
+ LoadingError::OutOfMemory(format!("loading image: {}", url))
}
cairo::Status::InvalidSize => {
- LoadingError::LimitExceeded(format!("image too big: {}", human_readable_url))
+ LoadingError::LimitExceeded(format!("image too big: {}", url))
}
_ => LoadingError::Unknown,
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]