Skip to content

Commit 103486f

Browse files
committed
perf: add #[inline] attribute to getters
1 parent 66fb439 commit 103486f

1 file changed

Lines changed: 63 additions & 0 deletions

File tree

helix-view/src/editor/config.rs

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,105 +48,156 @@ pub struct Lsp {
4848
impl Lsp {
4949
const DEFAULT: &'static str = "*";
5050

51+
#[inline]
5152
pub fn file(&self) -> &str {
5253
self.file.as_ref().map_or(Self::DEFAULT, |file| file)
5354
}
55+
56+
#[inline]
5457
pub fn module(&self) -> &str {
5558
self.module.as_ref().map_or(Self::DEFAULT, |module| module)
5659
}
60+
61+
#[inline]
5762
pub fn namespace(&self) -> &str {
5863
self.namespace
5964
.as_ref()
6065
.map_or(Self::DEFAULT, |namespace| namespace)
6166
}
67+
68+
#[inline]
6269
pub fn package(&self) -> &str {
6370
self.package
6471
.as_ref()
6572
.map_or(Self::DEFAULT, |package| package)
6673
}
74+
75+
#[inline]
6776
pub fn class(&self) -> &str {
6877
self.class.as_ref().map_or(Self::DEFAULT, |class| class)
6978
}
79+
80+
#[inline]
7081
pub fn method(&self) -> &str {
7182
self.method.as_ref().map_or(Self::DEFAULT, |method| method)
7283
}
84+
85+
#[inline]
7386
pub fn property(&self) -> &str {
7487
self.property
7588
.as_ref()
7689
.map_or(Self::DEFAULT, |property| property)
7790
}
91+
92+
#[inline]
7893
pub fn field(&self) -> &str {
7994
self.field.as_ref().map_or(Self::DEFAULT, |field| field)
8095
}
96+
97+
#[inline]
8198
pub fn constructor(&self) -> &str {
8299
self.constructor
83100
.as_ref()
84101
.map_or(Self::DEFAULT, |constructor| constructor)
85102
}
103+
104+
#[inline]
86105
pub fn r#enum(&self) -> &str {
87106
self.r#enum.as_ref().map_or(Self::DEFAULT, |r#enum| r#enum)
88107
}
108+
109+
#[inline]
89110
pub fn interface(&self) -> &str {
90111
self.interface
91112
.as_ref()
92113
.map_or(Self::DEFAULT, |interface| interface)
93114
}
115+
116+
#[inline]
94117
pub fn function(&self) -> &str {
95118
self.function
96119
.as_ref()
97120
.map_or(Self::DEFAULT, |function| function)
98121
}
122+
123+
#[inline]
99124
pub fn variable(&self) -> &str {
100125
self.variable
101126
.as_ref()
102127
.map_or(Self::DEFAULT, |variable| variable)
103128
}
129+
130+
#[inline]
104131
pub fn constant(&self) -> &str {
105132
self.constant
106133
.as_ref()
107134
.map_or(Self::DEFAULT, |constant| constant)
108135
}
136+
137+
#[inline]
109138
pub fn string(&self) -> &str {
110139
self.string.as_ref().map_or(Self::DEFAULT, |string| string)
111140
}
141+
142+
#[inline]
112143
pub fn number(&self) -> &str {
113144
self.number.as_ref().map_or(Self::DEFAULT, |number| number)
114145
}
146+
147+
#[inline]
115148
pub fn boolean(&self) -> &str {
116149
self.boolean
117150
.as_ref()
118151
.map_or(Self::DEFAULT, |boolean| boolean)
119152
}
153+
154+
#[inline]
120155
pub fn array(&self) -> &str {
121156
self.array.as_ref().map_or(Self::DEFAULT, |array| array)
122157
}
158+
159+
#[inline]
123160
pub fn object(&self) -> &str {
124161
self.object.as_ref().map_or(Self::DEFAULT, |object| object)
125162
}
163+
164+
#[inline]
126165
pub fn key(&self) -> &str {
127166
self.key.as_ref().map_or(Self::DEFAULT, |key| key)
128167
}
168+
169+
#[inline]
129170
pub fn null(&self) -> &str {
130171
self.null.as_ref().map_or(Self::DEFAULT, |null| null)
131172
}
173+
174+
#[inline]
132175
pub fn enum_member(&self) -> &str {
133176
self.enum_member
134177
.as_ref()
135178
.map_or(Self::DEFAULT, |enum_member| enum_member)
136179
}
180+
181+
#[inline]
137182
pub fn r#struct(&self) -> &str {
138183
self.r#struct
139184
.as_ref()
140185
.map_or(Self::DEFAULT, |r#struct| r#struct)
141186
}
187+
188+
#[inline]
142189
pub fn event(&self) -> &str {
143190
self.event.as_ref().map_or(Self::DEFAULT, |event| event)
144191
}
192+
193+
#[inline]
145194
pub fn operator(&self) -> &str {
146195
self.operator
147196
.as_ref()
148197
.map_or(Self::DEFAULT, |operator| operator)
149198
}
199+
200+
#[inline]
150201
pub fn type_parameter(&self) -> &str {
151202
self.type_parameter
152203
.as_ref()
@@ -178,17 +229,24 @@ pub struct Diagnostic {
178229
impl Diagnostic {
179230
const DEFAULT: &'static str = "●";
180231

232+
#[inline]
181233
pub fn hint(&self) -> &str {
182234
self.hint.as_ref().map_or(Self::DEFAULT, |hint| hint)
183235
}
236+
237+
#[inline]
184238
pub fn info(&self) -> &str {
185239
self.info.as_ref().map_or(Self::DEFAULT, |info| info)
186240
}
241+
242+
#[inline]
187243
pub fn warning(&self) -> &str {
188244
self.warning
189245
.as_ref()
190246
.map_or(Self::DEFAULT, |warning| warning)
191247
}
248+
249+
#[inline]
192250
pub fn error(&self) -> &str {
193251
self.error.as_ref().map_or(Self::DEFAULT, |error| error)
194252
}
@@ -202,6 +260,7 @@ pub struct Vcs {
202260
impl Vcs {
203261
const DEFAULT: &'static str = "";
204262

263+
#[inline]
205264
pub fn icon(&self) -> &str {
206265
self.icon
207266
.as_ref()
@@ -217,11 +276,13 @@ pub struct Mime {
217276
}
218277

219278
impl Mime {
279+
#[inline]
220280
pub fn directory(&self) -> &str {
221281
self.directory.as_ref().map_or("", |directory| directory)
222282
}
223283

224284
// Returns the symbol that matches the name, if any, otherwise returns the name back.
285+
#[inline]
225286
pub fn get<'name, 'mime: 'name>(&'mime self, r#type: &'name str) -> &'name str {
226287
self.mime.get(r#type).map_or(r#type, |mime| mime)
227288
}
@@ -237,12 +298,14 @@ impl Dap {
237298
const DEFAULT_VERIFIED: &'static str = "●";
238299
const DEFAULT_UNVERIFIED: &'static str = "◯";
239300

301+
#[inline]
240302
pub fn verified(&self) -> &str {
241303
self.verified
242304
.as_ref()
243305
.map_or(Self::DEFAULT_VERIFIED, |verified| verified)
244306
}
245307

308+
#[inline]
246309
pub fn unverified(&self) -> &str {
247310
self.verified
248311
.as_ref()

0 commit comments

Comments
 (0)