perf: use Arc<str> for repetitive DTO fields to eliminate clone allocations
Replace String with Arc<str> for fields that contain repeated static values (mime_type, icon_class, icon_special_class, category) in FileDto, FolderDto, and OptimizedFileContent. These fields are computed from ~40 static lookup tables and cloned on every request. With Arc<str>, clone becomes O(1) atomic increment instead of O(n) heap allocation — saving thousands of allocations/s under load. Fields kept as String: id, name, path, folder_id, owner_id (unique per item, rarely cloned). Zero API impact — serde serializes Arc<str> identically to String. https://claude.ai/code/session_01EbAFEfyJNLRmJHmmYDX3Tt
This commit is contained in:
+1
-1
@@ -505,7 +505,7 @@ impl FileRetrievalUseCase for StubFileRetrievalUseCase {
|
||||
FileDto::default(),
|
||||
OptimizedFileContent::Bytes {
|
||||
data: Bytes::new(),
|
||||
mime_type: String::new(),
|
||||
mime_type: Arc::from(""),
|
||||
was_transcoded: false,
|
||||
},
|
||||
))
|
||||
|
||||
Reference in New Issue
Block a user