1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-09 21:40:33 +02:00

Micro-optimize update-port-position.

* libguile/ports.c (update_port_position): Only fetch line if we need to
  increment it.
This commit is contained in:
Andy Wingo 2017-03-09 15:53:47 +01:00
parent 7de77bf7d8
commit f71c2c1260

View file

@ -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':
{
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);