summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2017-03-09 15:53:47 +0100
committerAndy Wingo <wingo@pobox.com>2017-03-09 17:24:06 +0100
commitf71c2c12609abfac9af7d38ea99f89a1f51b6992 (patch)
treefe91da5e833b6c84f09162817870b90f5f42f717
parent7de77bf7d8016446b4fcddb36e588406266ec40a (diff)
downloadguile-f71c2c12609abfac9af7d38ea99f89a1f51b6992.tar.gz
Micro-optimize update-port-position.
* libguile/ports.c (update_port_position): Only fetch line if we need to increment it.
-rw-r--r--libguile/ports.c8
1 files 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);