mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-25 04:54:07 +00:00
Avoid clone in src/syncback/file_names.rs
This commit is contained in:
parent
3a6aae65f7
commit
0e1364945f
1 changed files with 7 additions and 8 deletions
|
|
@ -8,11 +8,11 @@ use rbx_dom_weak::Instance;
|
||||||
|
|
||||||
use crate::{snapshot::InstanceWithMeta, snapshot_middleware::Middleware};
|
use crate::{snapshot::InstanceWithMeta, snapshot_middleware::Middleware};
|
||||||
|
|
||||||
pub fn name_for_inst<'old>(
|
pub fn name_for_inst<'a>(
|
||||||
middleware: Middleware,
|
middleware: Middleware,
|
||||||
new_inst: &Instance,
|
new_inst: &'a Instance,
|
||||||
old_inst: Option<InstanceWithMeta<'old>>,
|
old_inst: Option<InstanceWithMeta<'a>>,
|
||||||
) -> anyhow::Result<Cow<'old, str>> {
|
) -> anyhow::Result<Cow<'a, str>> {
|
||||||
if let Some(old_inst) = old_inst {
|
if let Some(old_inst) = old_inst {
|
||||||
if let Some(source) = old_inst.metadata().relevant_paths.first() {
|
if let Some(source) = old_inst.metadata().relevant_paths.first() {
|
||||||
source
|
source
|
||||||
|
|
@ -36,12 +36,11 @@ pub fn name_for_inst<'old>(
|
||||||
| Middleware::ServerScriptDir
|
| Middleware::ServerScriptDir
|
||||||
| Middleware::ClientScriptDir
|
| Middleware::ClientScriptDir
|
||||||
| Middleware::ModuleScriptDir => {
|
| Middleware::ModuleScriptDir => {
|
||||||
let name = if validate_file_name(&new_inst.name).is_err() {
|
if validate_file_name(&new_inst.name).is_err() {
|
||||||
Cow::Owned(slugify_name(&new_inst.name))
|
Cow::Owned(slugify_name(&new_inst.name))
|
||||||
} else {
|
} else {
|
||||||
Cow::Owned(new_inst.name.clone())
|
Cow::Borrowed(&new_inst.name)
|
||||||
};
|
}
|
||||||
name
|
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
let extension = extension_for_middleware(middleware);
|
let extension = extension_for_middleware(middleware);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue