diff options
| author | Roberto I <roberto@inf.puc-rio.br> | 2025-11-11 14:40:30 -0300 |
|---|---|---|
| committer | Roberto I <roberto@inf.puc-rio.br> | 2025-11-11 14:40:30 -0300 |
| commit | 5b7d9987642f72d44223a8e5e79e013bb2b3d579 (patch) | |
| tree | 0a755e85069f2c19609500151fec5b1e6ff30f88 /lvm.c | |
| parent | 81f4def54f440e045b1401f11ef78b65b56b7abe (diff) | |
| download | lua-5b7d9987642f72d44223a8e5e79e013bb2b3d579.tar.gz lua-5b7d9987642f72d44223a8e5e79e013bb2b3d579.tar.bz2 lua-5b7d9987642f72d44223a8e5e79e013bb2b3d579.zip | |
External strings are as good as internal ones
A '__mode' metafield and an "n" key both can be external strings.
Diffstat (limited to 'lvm.c')
| -rw-r--r-- | lvm.c | 9 |
1 files changed, 7 insertions, 2 deletions
| @@ -657,6 +657,11 @@ int luaV_equalobj (lua_State *L, const TValue *t1, const TValue *t2) { | |||
| 657 | #define tostring(L,o) \ | 657 | #define tostring(L,o) \ |
| 658 | (ttisstring(o) || (cvt2str(o) && (luaO_tostring(L, o), 1))) | 658 | (ttisstring(o) || (cvt2str(o) && (luaO_tostring(L, o), 1))) |
| 659 | 659 | ||
| 660 | /* | ||
| 661 | ** Check whether object is a short empty string to optimize concatenation. | ||
| 662 | ** (External strings can be empty too; they will be concatenated like | ||
| 663 | ** non-empty ones.) | ||
| 664 | */ | ||
| 660 | #define isemptystr(o) (ttisshrstring(o) && tsvalue(o)->shrlen == 0) | 665 | #define isemptystr(o) (ttisshrstring(o) && tsvalue(o)->shrlen == 0) |
| 661 | 666 | ||
| 662 | /* copy strings in stack from top - n up to top - 1 to buffer */ | 667 | /* copy strings in stack from top - n up to top - 1 to buffer */ |
| @@ -691,8 +696,8 @@ void luaV_concat (lua_State *L, int total) { | |||
| 691 | setobjs2s(L, top - 2, top - 1); /* result is second op. */ | 696 | setobjs2s(L, top - 2, top - 1); /* result is second op. */ |
| 692 | } | 697 | } |
| 693 | else { | 698 | else { |
| 694 | /* at least two non-empty string values; get as many as possible */ | 699 | /* at least two string values; get as many as possible */ |
| 695 | size_t tl = tsslen(tsvalue(s2v(top - 1))); | 700 | size_t tl = tsslen(tsvalue(s2v(top - 1))); /* total length */ |
| 696 | TString *ts; | 701 | TString *ts; |
| 697 | /* collect total length and number of strings */ | 702 | /* collect total length and number of strings */ |
| 698 | for (n = 1; n < total && tostring(L, s2v(top - n - 1)); n++) { | 703 | for (n = 1; n < total && tostring(L, s2v(top - n - 1)); n++) { |
