diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-03-16 16:42:58 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-03-16 16:42:58 +0000 |
commit | adcc89137d3feea8f19fad461bbde6f4bce048e5 (patch) | |
tree | 160af959553ce57fdfcbc0a6c79bafcc3611aeea /crates/ra_ide_db | |
parent | 648df02953a6ebf87a5876668eceba208687e8a7 (diff) | |
parent | 9faea2364dee4fbc9391ad233c570b70256ef002 (diff) |
Merge #3584
3584: Switch to dynamic dispatch r=matklad a=matklad
Benches are in https://github.com/rust-analyzer/rust-analyzer/issues/1987#issuecomment-598807185
TL;DR:
* 33% faster release build
* slightly worse/same perf
* no changes for debug build
* slightly smaller binary
cc @flodiebold I genuinely don't know if it is a good idea or not.
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_ide_db')
-rw-r--r-- | crates/ra_ide_db/src/lib.rs | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/crates/ra_ide_db/src/lib.rs b/crates/ra_ide_db/src/lib.rs index fc1b19def..4faeefa8d 100644 --- a/crates/ra_ide_db/src/lib.rs +++ b/crates/ra_ide_db/src/lib.rs | |||
@@ -14,10 +14,11 @@ mod wasm_shims; | |||
14 | 14 | ||
15 | use std::sync::Arc; | 15 | use std::sync::Arc; |
16 | 16 | ||
17 | use hir::db::{AstDatabase, DefDatabase}; | ||
17 | use ra_db::{ | 18 | use ra_db::{ |
18 | salsa::{self, Database, Durability}, | 19 | salsa::{self, Database, Durability}, |
19 | Canceled, CheckCanceled, CrateId, FileId, FileLoader, FileLoaderDelegate, RelativePath, | 20 | Canceled, CheckCanceled, CrateId, FileId, FileLoader, FileLoaderDelegate, RelativePath, |
20 | SourceDatabase, SourceRootId, | 21 | SourceDatabase, SourceRootId, Upcast, |
21 | }; | 22 | }; |
22 | use rustc_hash::FxHashMap; | 23 | use rustc_hash::FxHashMap; |
23 | 24 | ||
@@ -41,6 +42,18 @@ pub struct RootDatabase { | |||
41 | pub last_gc_check: crate::wasm_shims::Instant, | 42 | pub last_gc_check: crate::wasm_shims::Instant, |
42 | } | 43 | } |
43 | 44 | ||
45 | impl Upcast<dyn AstDatabase> for RootDatabase { | ||
46 | fn upcast(&self) -> &(dyn AstDatabase + 'static) { | ||
47 | &*self | ||
48 | } | ||
49 | } | ||
50 | |||
51 | impl Upcast<dyn DefDatabase> for RootDatabase { | ||
52 | fn upcast(&self) -> &(dyn DefDatabase + 'static) { | ||
53 | &*self | ||
54 | } | ||
55 | } | ||
56 | |||
44 | impl FileLoader for RootDatabase { | 57 | impl FileLoader for RootDatabase { |
45 | fn file_text(&self, file_id: FileId) -> Arc<String> { | 58 | fn file_text(&self, file_id: FileId) -> Arc<String> { |
46 | FileLoaderDelegate(self).file_text(file_id) | 59 | FileLoaderDelegate(self).file_text(file_id) |