1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

cleanup: replace C for loops with range

This commit is contained in:
spaceface777
2020-02-24 17:55:16 +01:00
committed by GitHub
parent 5918946feb
commit ef8c1203b4
50 changed files with 168 additions and 170 deletions

View File

@@ -226,7 +226,7 @@ pub fn new_context(cfg gg.Cfg) &FreeType {
// Gen texture
// Load first 128 characters of ASCII set
mut chars := []Character
for c := 0; c < 128; c++ {
for c in 0..128 {
ch := ft_load_char(face, i64(c))
// s := utf32_to_str(uint(0x043f))
// s := 'п'
@@ -309,7 +309,7 @@ fn (ctx mut FreeType) private_draw_text(_x, _y int, utext ustring, cfg gx.TextCf
gl.bind_vao(ctx.vao)
// Iterate through all characters
// utext := text.ustring()
for i := 0; i < utext.len; i++ {
for i in 0..utext.len {
_rune := utext.at(i)
// println('$i => $_rune')
mut ch := Character{}
@@ -325,7 +325,7 @@ fn (ctx mut FreeType) private_draw_text(_x, _y int, utext ustring, cfg gx.TextCf
}
else if _rune.len > 1 {
// TODO O(1) use map
for j := 0; j < ctx.utf_runes.len; j++ {
for j in 0..ctx.utf_runes.len {
rune_j := ctx.utf_runes[j]
if rune_j==_rune {
ch = ctx.utf_chars[j]
@@ -406,7 +406,7 @@ pub fn (ctx mut FreeType) text_size(s string) (int, int) {
mut maxy := u32(0)
mut _rune := ''
mut ch := Character{}
for i := 0; i < utext.len; i++ {
for i in 0..utext.len {
_rune = utext.at(i)
ch = Character{}
mut found := false
@@ -421,7 +421,7 @@ pub fn (ctx mut FreeType) text_size(s string) (int, int) {
}
else if _rune.len > 1 {
// TODO O(1) use map
for j := 0; j < ctx.utf_runes.len; j++ {
for j in 0..ctx.utf_runes.len {
rune_j := ctx.utf_runes[j]
if rune_j==_rune {
ch = ctx.utf_chars[j]