From f71c2c12609abfac9af7d38ea99f89a1f51b6992 Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Thu, 9 Mar 2017 15:53:47 +0100 Subject: [PATCH] Micro-optimize update-port-position. * libguile/ports.c (update_port_position): Only fetch line if we need to increment it. --- libguile/ports.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libguile/ports.c b/libguile/ports.c index 1be4a3778..2a25cd58e 100644 --- a/libguile/ports.c +++ b/libguile/ports.c @@ -1678,7 +1678,6 @@ scm_c_read (SCM port, void *buffer, size_t size) static inline void update_port_position (SCM position, scm_t_wchar c) { - long line = scm_to_long (scm_port_position_line (position)); int column = scm_to_int (scm_port_position_column (position)); switch (c) @@ -1691,8 +1690,11 @@ update_port_position (SCM position, scm_t_wchar c) scm_port_position_set_column (position, scm_from_int (column - 1)); break; case '\n': - scm_port_position_set_line (position, scm_from_long (line + 1)); - scm_port_position_set_column (position, SCM_INUM0); + { + long line = scm_to_long (scm_port_position_line (position)); + scm_port_position_set_line (position, scm_from_long (line + 1)); + scm_port_position_set_column (position, SCM_INUM0); + } break; case '\r': scm_port_position_set_column (position, SCM_INUM0);