1
0
Fork 0
mirror of https://github.com/alacritty/alacritty.git synced 2024-11-18 13:55:23 -05:00

Refactor darwin code

The ascent calculation on darwin was more complicated than it needed to
be. By running a `.ceil()` instead of adding one, checking if it's 0,
substracting if it is, and then flooring it, a few instructions could be
shaved off.
This commit is contained in:
Christian Duerr 2017-12-10 14:00:18 +01:00 committed by Joe Wilm
parent fe29b8c687
commit 44251d9dbb

View file

@ -475,13 +475,11 @@ impl Font {
// Get the top of the bounding box // Get the top of the bounding box
let metrics = self.metrics(); let metrics = self.metrics();
let height = metrics.line_height; let height = metrics.line_height;
let mut ascent = height - self.ct_font.descent() + 1.; let ascent = (height - self.ct_font.descent()).ceil();
if ascent.floor() == ascent {
// Fix off-by-one with an exact X.0 ascent
ascent -= 1.;
}
// Get the width of the cell // Get the width of the cell
let width = self.glyph_advance('0') as i32; let width = self.glyph_advance('0') as i32;
// Return the new custom glyph // Return the new custom glyph
if character == super::BEAM_CURSOR_CHAR { if character == super::BEAM_CURSOR_CHAR {
return super::get_beam_cursor_glyph(ascent as i32, height as i32, width); return super::get_beam_cursor_glyph(ascent as i32, height as i32, width);