282 Commits

Author SHA1 Message Date
Delyan Angelov
c5e8ad19df
builtin: implement a s.hex() method, allowing shortening s.bytes().hex() chains, and reducing the intermediate allocations; add tests for it (#22540) 2024-10-16 14:18:10 +03:00
yuyi
5e00270ef2
builtin: cleanup push_many()/push_many_noscan() (#22383) 2024-10-01 20:16:13 +03:00
Delyan Angelov
b8c649b62a
builtin: small cleanup in array.free() (make debugging easier) (#22173) 2024-09-07 18:22:16 +03:00
yuyi
c51d30bf53
fmt: fix alignment of struct init fields (#22025) 2024-08-11 09:11:24 +03:00
yuyi
79ee4ae046
fmt: fix alignment of enumeration types (#21999) 2024-08-07 15:46:50 +03:00
Delyan Angelov
6f20516a34
builtin: panic on trying to grow arrays with capacity bigger than 2^31, instead of overflowing a.cap (partial fix for #21918) (#21947) 2024-07-28 23:17:59 +03:00
Turiiya
f77bb32044
all: fix typos (#21089) 2024-03-25 12:18:27 +02:00
Anton
763f94388b
all: update copyright year (#20334) 2024-01-01 23:29:54 +02:00
Joe C
757929392e
all: update attributes to use new syntax 2023-11-15 16:16:01 +11:00
Artem Yurchenko
97f7c3f609
builtin: move min/max integer values consts from math to builtin (#19809) 2023-11-08 20:43:48 +02:00
Turiiya
9051ac8921
all: fix typos (#19634) 2023-10-23 21:21:15 +03:00
Delyan Angelov
ec9ac7715a
builtin: add an unsafe { a.reset() } method, for quickly setting all bytes in an array to 0 2023-10-01 07:22:42 +03:00
yuyi
ec30256c7f
builtin: cleanup obsolete function in string.v and array.v (#19451) 2023-09-27 19:49:33 +03:00
yuyi
981f76cd04
builtin, cgen: fix printing slice of fn call string (#19450) 2023-09-27 14:53:56 +03:00
Delyan Angelov
7ffa8c13bf
vlib: remove functions and fields, deprecated before 2023-03-20
* remove []int.reduce in favour of arrays.fold
  * remove datatypes.Set.equal in favour of datatypes.Set.==
  * remove datatypes.Set.difference in favour of datatypes.Set.-
  * remove gg.Context.set_cfg in favour of gg.Context.set_text_cfg
  * remove gg.Context.timage_pip in favour of gg.Context.pipeline.alpha
  * remove os.is_writable_folder in favour of os.ensure_folder_is_writable

  Discovered with `v run cmd/tools/show_ancient_deprecations.v 180`
2023-09-16 17:16:54 +03:00
Delyan Angelov
fca8092523
builtin: fix the wording of panic messages, about sorting not working with -freestanding
Thanks @MPetr for spotting it.
2023-09-01 10:04:29 +03:00
Delyan Angelov
58b6ba81d1
builtin: implement array.sorted() and array.sorted_with_compare() methods, that do not modify their receivers (#19251) 2023-09-01 09:12:00 +03:00
Alexander Medvednikov
b29a084257 builtin: move array.data to the top of the struct 2023-07-23 18:53:19 +03:00
Delyan Angelov
6806086bf1
builtin: zero out internal map/array pointers on m.free(), to reduce the work for the GC mark phase for non escaping maps/arrays, used in hot loops (#18415) 2023-06-14 15:00:36 +03:00
Alexander Medvednikov
6756d28595 all: 2023 copyright 2023-03-28 22:55:57 +02:00
yuyi
93a3f5ff7d
builtin, cgen: fix array of struct with map field initialize (fix #17325) (#17340) 2023-02-18 20:34:15 +02:00
Delyan Angelov
fc5826b7ca
cgen: minimise sizeof(EmptyStruct) to 0 for gcc/clang and to 1 for tcc/msvc, by changing EMPTY_STRUCT_DECLARATION and EMPTY_STRUCT_INITIALIZATION (#16733) 2022-12-22 21:47:39 +02:00
Delyan Angelov
f9043c84a7
builtin: optimise the initialisation of the common 1 byte element arrays []u8 2022-12-22 20:41:32 +02:00
Alexander Medvednikov
88e33a83de gg: fix draw_image on macos native; vcreate: vweb template 2022-12-21 19:33:37 +03:00
l-m
acbd93b54c
builtin: add .nogrow and .nofree flags to array (#16661) 2022-12-14 09:44:14 +02:00
yuyi
69f7c45bec
builtin: fix array init with array default (#16664) 2022-12-13 18:05:33 +02:00
yuyi
017ace6ea7
vfmt: change all '$expr' to '${expr}' (#16428) 2022-11-15 16:53:13 +03:00
Delyan Angelov
9edb48571f
pref,cgen: support -no-bounds-checking, instead of -d no_bounds_checking, and make it enable direct_array_access for all fns/methods. 2022-10-30 14:39:45 +02:00
ChAoS_UnItY
95f57e9206
builtin: deprecate array.reduce in favour of arrays.fold (#16001) 2022-10-09 10:29:50 +03:00
Delyan Angelov
7e69619add
builtin, compiler: replace isnil(x) calls with x == unsafe { nil } (a little faster without -prod) (#15759) 2022-09-15 14:59:37 +03:00
Larpon
9dd8228f91
arrays: move carray_to_varray from builtin, make it generic (#15503) 2022-08-23 11:12:50 +03:00
Larpon
dda475bcc8
builtin: add carray_to_varray, closes #15493 (#15499) 2022-08-22 20:15:54 +03:00
Alexander Medvednikov
dc79f1392b all: voidptr(0) => unsafe { nil } (p.2) 2022-07-21 20:51:54 +03:00
yuyi
01fdd5d07f
cgen: add a minor optimisation for array.push_many (#14770) 2022-06-17 09:44:13 +03:00
Ikko Ashimine
7b25957a26
builtin: fix typo in array.v (#14688) 2022-06-05 18:49:40 +03:00
Delyan Angelov
56cf0b0a2e
builtin: inline manually isnil calls in array.push_many (very frequently called) 2022-05-07 12:55:40 +03:00
Delyan Angelov
1a4d9017e2
builtin: improve support for large arrays ([]int{len: 1_000_000_000} now works), fix an arr.repeat() bug (#14294) 2022-05-04 18:42:06 +03:00
Delyan Angelov
cc8803c602
builtin: fix failing embed_file_test.v (pub fn (data &u8) vbytes(len int) []u8 {) 2022-04-15 19:57:00 +03:00
Alexander Medvednikov
fbb9e65c0f all: ~500 more byte=>u8 2022-04-15 18:25:45 +03:00
Alexander Medvednikov
fb192d949b all: replace []byte with []u8 2022-04-15 15:35:35 +03:00
Alexander Medvednikov
d4a0d6f73c all: byte => u8 2022-04-15 14:58:56 +03:00
Alexander Medvednikov
e6ff1508d2 all: make u8 the primary type, byte the alias 2022-04-15 13:43:03 +03:00
Nick Treleaven
782d5374c9
builtin: add an array.drop(n) method (#13907) 2022-04-03 17:05:50 +03:00
yuyi
8c55a9ecd3
builtin: minor optimization of array.push() and array.push_noscan() (#13904) 2022-04-03 11:04:18 +03:00
Nick Treleaven
a87cd9663e
vdoc: highlight inline examples for -f html (#13879) 2022-03-31 19:32:32 +03:00
Nick Treleaven
02f72c8230
builtin: improve docs for array methods that take an it expression, like .map, .filter etc (#13836)
Move explanation about boolean `it` expressions to `filter`, as `sort`
doesn't take a boolean expression. Also move `any` example.
Add 2 filter examples.
Add map example from docs.md.
2022-03-27 14:28:15 +03:00
Delyan Angelov
5b492e26dd
builtin: support a.flags.set(.noslices | .noshrink), use it in the particles example (#13818) 2022-03-24 23:37:13 +02:00
Nick Treleaven
afbccf79f7
builtin: don't memdup element for array.pop (depends on how cgen works) (#13789)
The voidptr returned is immediately dereferenced in cgen so the memory
is copied before the array can be appended to: `*(int*)array_pop(&a)`
2022-03-21 23:34:35 +02:00
Delyan Angelov
71edaa071a
builtin: use malloc, instead of calloc in array.ensure_cap/1 2022-03-20 15:08:42 +02:00
Delyan Angelov
8ab0bcb6aa
Revert "builtin: improve performance for common array ops, based on VTune analysis"
This reverts commit 57db2615380801f76a1e7d14d27d52a57d597b42.
2022-03-20 12:57:27 +02:00