mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parser: array init: []string => []string{}
This commit is contained in:
@@ -531,7 +531,7 @@ pub fn compare_f32(a, b &f32) int {
|
||||
// a.pointers() returns a new array, where each element
|
||||
// is the address of the corresponding element in a.
|
||||
pub fn (a array) pointers() []voidptr {
|
||||
mut res := []voidptr
|
||||
mut res := []voidptr{}
|
||||
for i in 0..a.len {
|
||||
res << byteptr(a.data) + i * a.element_size
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ fn print_backtrace_skipping_top_frames_linux(skipframes int) bool {
|
||||
buffer := [100]byteptr
|
||||
nr_ptrs := backtrace(buffer, 100)
|
||||
nr_actual_frames := nr_ptrs - skipframes
|
||||
mut sframes := []string
|
||||
mut sframes := []string{}
|
||||
//////csymbols := backtrace_symbols(*voidptr(&buffer[skipframes]), nr_actual_frames)
|
||||
csymbols := backtrace_symbols(&buffer[skipframes], nr_actual_frames)
|
||||
for i in 0 .. nr_actual_frames {
|
||||
|
||||
@@ -144,7 +144,7 @@ pub fn (s string) replace(rep, with string) string {
|
||||
}
|
||||
// TODO PERF Allocating ints is expensive. Should be a stack array
|
||||
// Get locations of all reps within this string
|
||||
mut idxs := []int
|
||||
mut idxs := []int{}
|
||||
mut idx := 0
|
||||
for {
|
||||
idx = s.index_after(rep, idx)
|
||||
@@ -231,7 +231,7 @@ pub fn (s string) replace_each(vals []string) string {
|
||||
// Remember positions of all rep strings, and calculate the length
|
||||
// of the new string to do just one allocation.
|
||||
mut new_len := s.len
|
||||
mut idxs := []RepIndex
|
||||
mut idxs := []RepIndex{}
|
||||
mut idx := 0
|
||||
for rep_i := 0; rep_i < vals.len; rep_i += 2 {
|
||||
// vals: ['rep1, 'with1', 'rep2', 'with2']
|
||||
@@ -407,7 +407,7 @@ The last returned element has the remainder of the string, even if
|
||||
the remainder contains more `delim` substrings.
|
||||
*/
|
||||
pub fn (s string) split_nth(delim string, nth int) []string {
|
||||
mut res := []string
|
||||
mut res := []string{}
|
||||
mut i := 0
|
||||
if delim.len == 0 {
|
||||
i = 1
|
||||
@@ -458,7 +458,7 @@ pub fn (s string) split_nth(delim string, nth int) []string {
|
||||
}
|
||||
|
||||
pub fn (s string) split_into_lines() []string {
|
||||
mut res := []string
|
||||
mut res := []string{}
|
||||
if s.len == 0 {
|
||||
return res
|
||||
}
|
||||
@@ -788,7 +788,7 @@ pub fn (s string) is_capital() bool {
|
||||
|
||||
pub fn (s string) title() string {
|
||||
words := s.split(' ')
|
||||
mut tit := []string
|
||||
mut tit := []string{}
|
||||
for word in words {
|
||||
tit << word.capitalize()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user