Skip to content

Conversation

@Tristramg
Copy link
Contributor

No description provided.

Signed-off-by: Tristram Gräbener <tristram+git@tristramg.eu>
Comment on lines +237 to +238
.unwrap_or(&"unknown".to_owned())
.to_owned();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of using to_owned for "unknown", taking a reference, then using again .to_owned a second time (2 allocations in the case of "unknown"), you should be able to invert that with the following code, isn’t it ?

Suggested change
.unwrap_or(&"unknown".to_owned())
.to_owned();
.map(ToOwned::to_owned)
.unwrap_or("unknown".to_owned());

And also, maybe returning a NonBlankString directly from this function would make it more obvious why the default value is "unknown" and not "".

Suggested change
.unwrap_or(&"unknown".to_owned())
.to_owned();
.map(NonBlankString::from)
.unwrap_or(NonBlankString::from("unknown"));

@woshilapin woshilapin requested a review from hamz2a January 22, 2026 10:44
Copy link
Contributor

@hamz2a hamz2a left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:editoast Work on Editoast Service

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

4 participants