aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2019-07-20 10:46:09 +0200
committerGitHub <noreply@github.com>2019-07-20 10:46:09 +0200
commitf55c1e4233a44a7453a61eba0eed632d3c1f97cb (patch)
tree177a7b5138631199fb08892a0e396593eb87e045 /src
parentafef973262bea3fe1563dc0571bb4168ac0914aa (diff)
downloadrneovim-f55c1e4233a44a7453a61eba0eed632d3c1f97cb.tar.gz
rneovim-f55c1e4233a44a7453a61eba0eed632d3c1f97cb.tar.bz2
rneovim-f55c1e4233a44a7453a61eba0eed632d3c1f97cb.zip
reltimefloat(): allow negative result #10544
For "backwards" duration, reltimefloat() should return negative value like its counterpart reltimestr(). ref bab24a88ab48 ref 06af88cd72ea ref #10521 fix #10452
Diffstat (limited to 'src')
-rw-r--r--src/nvim/eval.c10
-rw-r--r--src/nvim/profile.c2
2 files changed, 3 insertions, 9 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index aa79d4ce5f..eb2a6ff32a 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -13843,11 +13843,7 @@ static void f_reltime(typval_T *argvars, typval_T *rettv, FunPtr fptr)
tv_list_append_number(rettv->vval.v_list, u.split.low);
}
-/// f_reltimestr - return a string that represents the value of {time}
-///
-/// @return The string representation of the argument, the format is the
-/// number of seconds followed by a dot, followed by the number
-/// of microseconds.
+/// "reltimestr()" function
static void f_reltimestr(typval_T *argvars, typval_T *rettv, FunPtr fptr)
FUNC_ATTR_NONNULL_ALL
{
@@ -16578,9 +16574,7 @@ static void f_uniq(typval_T *argvars, typval_T *rettv, FunPtr fptr)
do_sort_uniq(argvars, rettv, false);
}
-//
// "reltimefloat()" function
-//
static void f_reltimefloat(typval_T *argvars , typval_T *rettv, FunPtr fptr)
FUNC_ATTR_NONNULL_ALL
{
@@ -16589,7 +16583,7 @@ static void f_reltimefloat(typval_T *argvars , typval_T *rettv, FunPtr fptr)
rettv->v_type = VAR_FLOAT;
rettv->vval.v_float = 0;
if (list2proftime(&argvars[0], &tm) == OK) {
- rettv->vval.v_float = ((float_T)tm) / 1000000000;
+ rettv->vval.v_float = (float_T)profile_signed(tm) / 1000000000.0;
}
}
diff --git a/src/nvim/profile.c b/src/nvim/profile.c
index a6314e7b9d..0a5030edae 100644
--- a/src/nvim/profile.c
+++ b/src/nvim/profile.c
@@ -169,7 +169,7 @@ bool profile_equal(proftime_T tm1, proftime_T tm2) FUNC_ATTR_CONST
return tm1 == tm2;
}
-/// Converts a proftime_T value `tm` to a signed integer.
+/// Converts time duration `tm` (`profile_sub` result) to a signed integer.
///
/// @return signed representation of the given time value
int64_t profile_signed(proftime_T tm)