Skip to content
Myr

src/builtin.c: remove unnecessary jv_copy-s in type_error/type_error2

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Also fix doubled semicolon jv ret;; => jv ret;

authored by Emanuele Torre · committed by Nico Williams · parent d5590f9 · Browse files · 1 file+10 added−11 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+10 added−11 removed

  • other:+10 added−11 removed

1 file+10 added−11 removed

modified:src/builtin.c+10 added-11 removed
56 unmodified lines
575859static jv type_error(jv bad, const char* msg) {60 char errbuf[15];61 jv err = jv_invalid_with_msg(jv_string_fmt("%s (%s) %s",62 jv_kind_name(jv_get_kind(bad)),63 jv_dump_string_trunc(jv_copy(bad), errbuf, sizeof(errbuf)),61 const char *badkind = jv_kind_name(jv_get_kind(bad));62 jv err = jv_invalid_with_msg(jv_string_fmt("%s (%s) %s", badkind,63 jv_dump_string_trunc(bad, errbuf, sizeof(errbuf)),64 msg));65 jv_free(bad);65 return err;66}6768static jv type_error2(jv bad1, jv bad2, const char* msg) {69 char errbuf1[15],errbuf2[15];70 const char *badkind1 = jv_kind_name(jv_get_kind(bad1));71 const char *badkind2 = jv_kind_name(jv_get_kind(bad2));72 jv err = jv_invalid_with_msg(jv_string_fmt("%s (%s) and %s (%s) %s",72 jv_kind_name(jv_get_kind(bad1)),73 jv_dump_string_trunc(jv_copy(bad1), errbuf1, sizeof(errbuf1)),74 jv_kind_name(jv_get_kind(bad2)),75 jv_dump_string_trunc(jv_copy(bad2), errbuf2, sizeof(errbuf2)),73 badkind1,74 jv_dump_string_trunc(bad1, errbuf1, sizeof(errbuf1)),75 badkind2,76 jv_dump_string_trunc(bad2, errbuf2, sizeof(errbuf2)),77 msg));77 jv_free(bad1);78 jv_free(bad2);78 return err;79}8081static inline jv ret_error(jv bad, jv msg) {
199 unmodified lines
281 const char *astr = jv_string_value(a);282 const char *bstr = jv_string_value(b);283 size_t alen = jv_string_length_bytes(jv_copy(a));284 size_t blen = jv_string_length_bytes(jv_copy(b));286 jv ret;;285 jv ret;286287 if (alen < blen ||288 memcmp(astr + (alen - blen), bstr, blen) != 0)289 ret = jv_false();
1603 unmodified lines