chore: Cleanup QName::to_qualified_name
This commit is contained in:
parent
5dd21cdf8e
commit
547aac0e85
|
@ -5,7 +5,6 @@ use crate::avm2::script::TranslationUnit;
|
||||||
use crate::avm2::string::AvmString;
|
use crate::avm2::string::AvmString;
|
||||||
use crate::avm2::Error;
|
use crate::avm2::Error;
|
||||||
use gc_arena::{Collect, MutationContext};
|
use gc_arena::{Collect, MutationContext};
|
||||||
use std::fmt::Write;
|
|
||||||
use swf::avm2::types::{
|
use swf::avm2::types::{
|
||||||
Index, Multiname as AbcMultiname, Namespace as AbcNamespace, NamespaceSet as AbcNamespaceSet,
|
Index, Multiname as AbcMultiname, Namespace as AbcNamespace, NamespaceSet as AbcNamespaceSet,
|
||||||
};
|
};
|
||||||
|
@ -200,13 +199,11 @@ impl<'gc> QName<'gc> {
|
||||||
|
|
||||||
/// Converts this `QName` to a fully qualified name.
|
/// Converts this `QName` to a fully qualified name.
|
||||||
pub fn to_qualified_name(&self) -> String {
|
pub fn to_qualified_name(&self) -> String {
|
||||||
let mut result = String::new();
|
|
||||||
let uri = self.namespace().as_uri();
|
let uri = self.namespace().as_uri();
|
||||||
if !uri.is_empty() {
|
let name = self.local_name();
|
||||||
write!(result, "{}::", uri).expect("Write failed");
|
uri.is_empty()
|
||||||
}
|
.then(|| name.to_string())
|
||||||
result.push_str(&self.local_name());
|
.unwrap_or_else(|| format!("{}::{}", uri, name))
|
||||||
result
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn local_name(&self) -> AvmString<'gc> {
|
pub fn local_name(&self) -> AvmString<'gc> {
|
||||||
|
|
Loading…
Reference in New Issue