Skip to content

Commit 4181d43

Browse files
committed
Remove inline silliness from debug builders
Turns out it's basically a wash, codegen wise.
1 parent 3181213 commit 4181d43

File tree

1 file changed

+11
-60
lines changed

1 file changed

+11
-60
lines changed

src/libcore/fmt/builders.rs

Lines changed: 11 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,7 @@ pub fn debug_struct_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>, name: &str)
7373
impl<'a, 'b: 'a> DebugStruct<'a, 'b> {
7474
/// Adds a new field to the generated struct output.
7575
#[unstable(feature = "core", reason = "method was just created")]
76-
#[inline]
7776
pub fn field(mut self, name: &str, value: &fmt::Debug) -> DebugStruct<'a, 'b> {
78-
self.field_inner(name, value);
79-
self
80-
}
81-
82-
#[inline(never)]
83-
fn field_inner(&mut self, name: &str, value: &fmt::Debug) {
8477
self.result = self.result.and_then(|_| {
8578
let prefix = if self.has_fields {
8679
","
@@ -97,19 +90,13 @@ impl<'a, 'b: 'a> DebugStruct<'a, 'b> {
9790
});
9891

9992
self.has_fields = true;
93+
self
10094
}
10195

10296
/// Consumes the `DebugStruct`, finishing output and returning any error
10397
/// encountered.
10498
#[unstable(feature = "core", reason = "method was just created")]
105-
#[inline]
10699
pub fn finish(mut self) -> fmt::Result {
107-
self.finish_inner();
108-
self.result
109-
}
110-
111-
#[inline(never)]
112-
fn finish_inner(&mut self) {
113100
if self.has_fields {
114101
self.result = self.result.and_then(|_| {
115102
if self.is_pretty() {
@@ -119,6 +106,7 @@ impl<'a, 'b: 'a> DebugStruct<'a, 'b> {
119106
}
120107
});
121108
}
109+
self.result
122110
}
123111

124112
fn is_pretty(&self) -> bool {
@@ -148,14 +136,7 @@ pub fn debug_tuple_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>, name: &str) -> D
148136
impl<'a, 'b: 'a> DebugTuple<'a, 'b> {
149137
/// Adds a new field to the generated tuple struct output.
150138
#[unstable(feature = "core", reason = "method was just created")]
151-
#[inline]
152139
pub fn field(mut self, value: &fmt::Debug) -> DebugTuple<'a, 'b> {
153-
self.field_inner(value);
154-
self
155-
}
156-
157-
#[inline(never)]
158-
fn field_inner(&mut self, value: &fmt::Debug) {
159140
self.result = self.result.and_then(|_| {
160141
let (prefix, space) = if self.has_fields {
161142
(",", " ")
@@ -172,19 +153,13 @@ impl<'a, 'b: 'a> DebugTuple<'a, 'b> {
172153
});
173154

174155
self.has_fields = true;
156+
self
175157
}
176158

177159
/// Consumes the `DebugTuple`, finishing output and returning any error
178160
/// encountered.
179161
#[unstable(feature = "core", reason = "method was just created")]
180-
#[inline]
181162
pub fn finish(mut self) -> fmt::Result {
182-
self.finish_inner();
183-
self.result
184-
}
185-
186-
#[inline(never)]
187-
fn finish_inner(&mut self) {
188163
if self.has_fields {
189164
self.result = self.result.and_then(|_| {
190165
if self.is_pretty() {
@@ -194,6 +169,7 @@ impl<'a, 'b: 'a> DebugTuple<'a, 'b> {
194169
}
195170
});
196171
}
172+
self.result
197173
}
198174

199175
fn is_pretty(&self) -> bool {
@@ -223,14 +199,7 @@ pub fn debug_set_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>, name: &str) -> Deb
223199
impl<'a, 'b: 'a> DebugSet<'a, 'b> {
224200
/// Adds a new entry to the set output.
225201
#[unstable(feature = "core", reason = "method was just created")]
226-
#[inline]
227202
pub fn entry(mut self, entry: &fmt::Debug) -> DebugSet<'a, 'b> {
228-
self.entry_inner(entry);
229-
self
230-
}
231-
232-
#[inline(never)]
233-
fn entry_inner(&mut self, entry: &fmt::Debug) {
234203
self.result = self.result.and_then(|_| {
235204
let prefix = if self.has_fields {
236205
","
@@ -247,27 +216,21 @@ impl<'a, 'b: 'a> DebugSet<'a, 'b> {
247216
});
248217

249218
self.has_fields = true;
219+
self
250220
}
251221

252222
/// Consumes the `DebugSet`, finishing output and returning any error
253223
/// encountered.
254224
#[unstable(feature = "core", reason = "method was just created")]
255-
#[inline]
256225
pub fn finish(mut self) -> fmt::Result {
257-
self.finish_inner();
258-
self.result
259-
}
260-
261-
#[inline(never)]
262-
fn finish_inner(&mut self) {
263-
self.result = self.result.and_then(|_| {
226+
self.result.and_then(|_| {
264227
let end = match (self.has_fields, self.is_pretty()) {
265228
(false, _) => "}",
266229
(true, false) => " }",
267230
(true, true) => "\n}",
268231
};
269232
self.fmt.write_str(end)
270-
});
233+
})
271234
}
272235

273236
fn is_pretty(&self) -> bool {
@@ -297,14 +260,7 @@ pub fn debug_map_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>, name: &str) -> Deb
297260
impl<'a, 'b: 'a> DebugMap<'a, 'b> {
298261
/// Adds a new entry to the map output.
299262
#[unstable(feature = "core", reason = "method was just created")]
300-
#[inline]
301263
pub fn entry(mut self, key: &fmt::Debug, value: &fmt::Debug) -> DebugMap<'a, 'b> {
302-
self.entry_inner(key, value);
303-
self
304-
}
305-
306-
#[inline(never)]
307-
fn entry_inner(&mut self, key: &fmt::Debug, value: &fmt::Debug) {
308264
self.result = self.result.and_then(|_| {
309265
let prefix = if self.has_fields {
310266
","
@@ -321,27 +277,22 @@ impl<'a, 'b: 'a> DebugMap<'a, 'b> {
321277
});
322278

323279
self.has_fields = true;
280+
281+
self
324282
}
325283

326284
/// Consumes the `DebugMap`, finishing output and returning any error
327285
/// encountered.
328286
#[unstable(feature = "core", reason = "method was just created")]
329-
#[inline]
330287
pub fn finish(mut self) -> fmt::Result {
331-
self.finish_inner();
332-
self.result
333-
}
334-
335-
#[inline(never)]
336-
fn finish_inner(&mut self) {
337-
self.result = self.result.and_then(|_| {
288+
self.result.and_then(|_| {
338289
let end = match (self.has_fields, self.is_pretty()) {
339290
(false, _) => "}",
340291
(true, false) => " }",
341292
(true, true) => "\n}",
342293
};
343294
self.fmt.write_str(end)
344-
});
295+
})
345296
}
346297

347298
fn is_pretty(&self) -> bool {

0 commit comments

Comments
 (0)