Skip to content

Commit 36bca1d

Browse files
committed
COMMON: mid and replace performance
1 parent 73bd6f5 commit 36bca1d

File tree

3 files changed

+3
-7
lines changed

3 files changed

+3
-7
lines changed

src/common/blib_func.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@
2121
#include "common/messages.h"
2222
#include "common/keymap.h"
2323

24-
#if defined(_UnixOS)
25-
#include <unistd.h>
26-
#endif
27-
2824
struct code_array_node_s {
2925
var_t *v;
3026
var_int_t col;

src/common/var.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ int v_isempty(var_t *var) {
5050
return 1;
5151
}
5252

53-
int v_strlen(var_t *v) {
53+
int v_strlen(const var_t *v) {
5454
int result;
5555
if (v->type == V_STR) {
5656
result = v->v.p.size;
@@ -459,7 +459,7 @@ void v_set(var_t *dest, const var_t *src) {
459459
dest->v.i = src->v.i;
460460
break;
461461
case V_STR:
462-
dest->v.p.size = strlen(src->v.p.ptr) + 1;
462+
dest->v.p.size = v_strlen(src) + 1;
463463
dest->v.p.ptr = (char *)malloc(dest->v.p.size);
464464
strcpy(dest->v.p.ptr, src->v.p.ptr);
465465
break;

src/common/var.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ char *v_getstr(var_t *v);
659659
* @param v is the variable
660660
* @return the string length
661661
*/
662-
int v_strlen(var_t *v);
662+
int v_strlen(const var_t *v);
663663

664664
/**
665665
* @ingroup var

0 commit comments

Comments
 (0)