[Bf-blender-cvs] [ddf4f289687] master: Cleanup: reduce variable scope
Jacques Lucke
noreply at git.blender.org
Wed Sep 9 15:43:51 CEST 2020
Commit: ddf4f2896878e3fd4a0f79d712a5e7b900b0cf7e
Author: Jacques Lucke
Date: Wed Sep 9 15:43:09 2020 +0200
Branches: master
https://developer.blender.org/rBddf4f2896878e3fd4a0f79d712a5e7b900b0cf7e
Cleanup: reduce variable scope
===================================================================
M source/blender/blenfont/intern/blf.c
M source/blender/blenfont/intern/blf_dir.c
M source/blender/blenfont/intern/blf_font.c
M source/blender/blenfont/intern/blf_glyph.c
M source/blender/blenfont/intern/blf_thumbs.c
M source/blender/blenkernel/intern/CCGSubSurf.c
M source/blender/blenkernel/intern/CCGSubSurf_inline.h
M source/blender/blenkernel/intern/CCGSubSurf_legacy.c
M source/blender/blenkernel/intern/appdir.c
M source/blender/blenkernel/intern/armature_update.c
M source/blender/blenkernel/intern/bvhutils.c
M source/blender/blenkernel/intern/camera.c
M source/blender/blenkernel/intern/cloth.c
M source/blender/blenkernel/intern/collision.c
M source/blender/blenkernel/intern/colortools.c
M source/blender/blenkernel/intern/constraint.c
M source/blender/blenkernel/intern/crazyspace.c
M source/blender/blenkernel/intern/curve.c
M source/blender/blenkernel/intern/customdata.c
===================================================================
diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c
index c5c2bc3f3ba..547112ecf66 100644
--- a/source/blender/blenfont/intern/blf.c
+++ b/source/blender/blenfont/intern/blf.c
@@ -92,9 +92,7 @@ static FontBLF *blf_get(int fontid)
int BLF_init(void)
{
- int i;
-
- for (i = 0; i < BLF_MAX_FONT; i++) {
+ for (int i = 0; i < BLF_MAX_FONT; i++) {
global_font[i] = NULL;
}
@@ -111,11 +109,8 @@ void BLF_default_dpi(int dpi)
void BLF_exit(void)
{
- FontBLF *font;
- int i;
-
- for (i = 0; i < BLF_MAX_FONT; i++) {
- font = global_font[i];
+ for (int i = 0; i < BLF_MAX_FONT; i++) {
+ FontBLF *font = global_font[i];
if (font) {
blf_font_free(font);
global_font[i] = NULL;
@@ -127,11 +122,8 @@ void BLF_exit(void)
void BLF_cache_clear(void)
{
- FontBLF *font;
- int i;
-
- for (i = 0; i < BLF_MAX_FONT; i++) {
- font = global_font[i];
+ for (int i = 0; i < BLF_MAX_FONT; i++) {
+ FontBLF *font = global_font[i];
if (font) {
blf_glyph_cache_clear(font);
blf_kerning_cache_clear(font);
@@ -141,11 +133,8 @@ void BLF_cache_clear(void)
static int blf_search(const char *name)
{
- FontBLF *font;
- int i;
-
- for (i = 0; i < BLF_MAX_FONT; i++) {
- font = global_font[i];
+ for (int i = 0; i < BLF_MAX_FONT; i++) {
+ FontBLF *font = global_font[i];
if (font && (STREQ(font->name, name))) {
return i;
}
@@ -156,9 +145,7 @@ static int blf_search(const char *name)
static int blf_search_available(void)
{
- int i;
-
- for (i = 0; i < BLF_MAX_FONT; i++) {
+ for (int i = 0; i < BLF_MAX_FONT; i++) {
if (!global_font[i]) {
return i;
}
@@ -192,13 +179,10 @@ bool BLF_has_glyph(int fontid, unsigned int unicode)
int BLF_load(const char *name)
{
- FontBLF *font;
- int i;
-
/* check if we already load this font. */
- i = blf_search(name);
+ int i = blf_search(name);
if (i >= 0) {
- font = global_font[i];
+ FontBLF *font = global_font[i];
font->reference_count++;
return i;
}
@@ -208,26 +192,22 @@ int BLF_load(const char *name)
int BLF_load_unique(const char *name)
{
- FontBLF *font;
- char *filename;
- int i;
-
/* Don't search in the cache!! make a new
* object font, this is for keep fonts threads safe.
*/
- i = blf_search_available();
+ int i = blf_search_available();
if (i == -1) {
printf("Too many fonts!!!\n");
return -1;
}
- filename = blf_dir_search(name);
+ char *filename = blf_dir_search(name);
if (!filename) {
printf("Can't find font: %s\n", name);
return -1;
}
- font = blf_font_new(name, filename);
+ FontBLF *font = blf_font_new(name, filename);
MEM_freeN(filename);
if (!font) {
@@ -251,9 +231,7 @@ void BLF_metrics_attach(int fontid, unsigned char *mem, int mem_size)
int BLF_load_mem(const char *name, const unsigned char *mem, int mem_size)
{
- int i;
-
- i = blf_search(name);
+ int i = blf_search(name);
if (i >= 0) {
/*font = global_font[i];*/ /*UNUSED*/
return i;
@@ -263,14 +241,11 @@ int BLF_load_mem(const char *name, const unsigned char *mem, int mem_size)
int BLF_load_mem_unique(const char *name, const unsigned char *mem, int mem_size)
{
- FontBLF *font;
- int i;
-
/*
* Don't search in the cache, make a new object font!
* this is to keep the font thread safe.
*/
- i = blf_search_available();
+ int i = blf_search_available();
if (i == -1) {
printf("Too many fonts!!!\n");
return -1;
@@ -281,7 +256,7 @@ int BLF_load_mem_unique(const char *name, const unsigned char *mem, int mem_size
return -1;
}
- font = blf_font_new_from_mem(name, mem, mem_size);
+ FontBLF *font = blf_font_new_from_mem(name, mem, mem_size);
if (!font) {
printf("Can't load font: %s from memory!!\n", name);
return -1;
@@ -294,11 +269,8 @@ int BLF_load_mem_unique(const char *name, const unsigned char *mem, int mem_size
void BLF_unload(const char *name)
{
- FontBLF *font;
- int i;
-
- for (i = 0; i < BLF_MAX_FONT; i++) {
- font = global_font[i];
+ for (int i = 0; i < BLF_MAX_FONT; i++) {
+ FontBLF *font = global_font[i];
if (font && (STREQ(font->name, name))) {
BLI_assert(font->reference_count > 0);
diff --git a/source/blender/blenfont/intern/blf_dir.c b/source/blender/blenfont/intern/blf_dir.c
index 9603470615d..51d3849aa48 100644
--- a/source/blender/blenfont/intern/blf_dir.c
+++ b/source/blender/blenfont/intern/blf_dir.c
@@ -115,11 +115,8 @@ char **BLF_dir_get(int *ndir)
void BLF_dir_free(char **dirs, int count)
{
- char *path;
- int i;
-
- for (i = 0; i < count; i++) {
- path = dirs[i];
+ for (int i = 0; i < count; i++) {
+ char *path = dirs[i];
MEM_freeN(path);
}
MEM_freeN(dirs);
diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c
index 1b27b6dd4c1..1501ee07b66 100644
--- a/source/blender/blenfont/intern/blf_font.c
+++ b/source/blender/blenfont/intern/blf_font.c
@@ -316,8 +316,7 @@ static GlyphBLF **blf_font_ensure_ascii_table(FontBLF *font, GlyphCacheBLF *gc)
/* build ascii on demand */
if (glyph_ascii_table['0'] == NULL) {
GlyphBLF *g;
- unsigned int i;
- for (i = 0; i < 256; i++) {
+ for (uint i = 0; i < 256; i++) {
g = blf_glyph_search(gc, i);
if (!g) {
FT_UInt glyph_index = FT_Get_Char_Index(font->face, i);
diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c
index 8e74d5bba7c..f3c5c057dec 100644
--- a/source/blender/blenfont/intern/blf_glyph.c
+++ b/source/blender/blenfont/intern/blf_glyph.c
@@ -205,9 +205,7 @@ void blf_glyph_cache_clear(FontBLF *font)
void blf_glyph_cache_free(GlyphCacheBLF *gc)
{
GlyphBLF *g;
- unsigned int i;
-
- for (i = 0; i < ARRAY_SIZE(gc->bucket); i++) {
+ for (uint i = 0; i < ARRAY_SIZE(gc->bucket); i++) {
while ((g = BLI_pophead(&gc->bucket[i]))) {
blf_glyph_free(g);
}
diff --git a/source/blender/blenfont/intern/blf_thumbs.c b/source/blender/blenfont/intern/blf_thumbs.c
index 6aa39e3aa71..3153a55b697 100644
--- a/source/blender/blenfont/intern/blf_thumbs.c
+++ b/source/blender/blenfont/intern/blf_thumbs.c
@@ -67,7 +67,6 @@ void BLF_thumb_preview(const char *filename,
FontBLF *font;
GlyphCacheBLF *gc;
- int i;
/* Create a new blender font obj and fill it with default values */
font = blf_font_new("thumb_font", filename);
@@ -91,7 +90,7 @@ void BLF_thumb_preview(const char *filename,
blf_draw_buffer__start(font);
- for (i = 0; i < draw_str_lines; i++) {
+ for (int i = 0; i < draw_str_lines; i++) {
const char *draw_str_i18n = i18n_draw_str[i] != NULL ? i18n_draw_str[i] : draw_str[i];
const size_t draw_str_i18n_len = strlen(draw_str_i18n);
int draw_str_i18n_nbr = 0;
diff --git a/source/blender/blenkernel/intern/CCGSubSurf.c b/source/blender/blenkernel/intern/CCGSubSurf.c
index e3543290b65..ec2fb5f5bdb 100644
--- a/source/blender/blenkernel/intern/CCGSubSurf.c
+++ b/source/blender/blenkernel/intern/CCGSubSurf.c
@@ -72,8 +72,7 @@ static CCGVert *_vert_new(CCGVertHDL vHDL, CCGSubSurf *ss)
}
static void _vert_remEdge(CCGVert *v, CCGEdge *e)
{
- int i;
- for (i = 0; i < v->numEdges; i++) {
+ for (int i = 0; i < v->numEdges; i++) {
if (v->edges[i] == e) {
v->edges[i] = v->edges[--v->numEdges];
break;
@@ -82,8 +81,7 @@ static void _vert_remEdge(CCGVert *v, CCGEdge *e)
}
static void _vert_remFace(CCGVert *v, CCGFace *f)
{
- int i;
- for (i = 0; i < v->numFaces; i++) {
+ for (int i = 0; i < v->numFaces; i++) {
if (v->faces[i] == f) {
v->faces[i] = v->faces[--v->numFaces];
break;
@@ -104,8 +102,7 @@ static void _vert_addFace(CCGVert *v, CCGFace *f, CCGSubSurf *ss)
}
static CCGEdge *_vert_findEdgeTo(const CCGVert *v, const CCGVert *vQ)
{
- int i;
- for (i = 0; i < v->numEdges; i++) {
+ for (int i = 0; i < v->numEdges; i++) {
CCGEdge *e = v->edges[v->numEdges - 1 - i]; // XXX, note reverse
if ((e->v0 == v && e->v1 == vQ) || (e->v1 == v && e->v0 == vQ)) {
return e;
@@ -155,8 +152,7 @@ static CCGEdge *_edge_new(CCGEdgeHDL eHDL, CCGVert *v0, CCGVert *v1, float creas
}
static void _edge_remFace(CCGEdge *e, CCGFace *f)
{
- int i;
- for (i = 0; i < e->numFaces; i++) {
+ for (int i = 0; i < e->numFaces; i++) {
if (e->faces[i] == f) {
e->faces[i] = e->faces[--e->numFaces];
break;
@@ -205,13 +201,12 @@ static CCGFace *_face_new(
sizeof(CCGFace) + sizeof(CCGVert *) * numVerts + sizeof(CCGEdge *) * numVerts +
ss->meshIFC.vertDataSize * num_face_data + ss->meshIFC.faceUserSize);
byte *userData;
- int i;
f->numVerts = numVerts;
f->fHDL = fHDL;
f->flags = 0;
- for (i = 0; i < numVerts; i++) {
+ for (int i = 0; i < numVerts; i++) {
FACE_getVerts(f)[i] = verts[i];
FACE_getEdges(f)[i] = edges[i];
_vert_addFace(verts[i], f, ss);
@@ -1418,9 +1413,7 @@ CCGEdge *ccgSubSurf_getFaceEdge(CCGFace *f, int index)
}
int ccgSubSurf_getFaceEdgeIndex(CCGFace *f, CCGEdge *e)
{
- int i;
-
- for (i = 0; i < f->numVerts; i++) {
+ for (int i = 0; i < f->numVerts; i++) {
if (FACE_getEdges(f)[i] == e) {
return i;
}
diff --git a/source/blender/blenkernel/intern/CCGSubSurf_inline.h b/source/blender/blenkernel/intern/CCGSubSurf_inline.h
index 91a7129b433..4681602c071 100644
--- a/source/blender/blenkernel/intern/CCGSubSurf_inline.h
+++ b/source/blender/blenkernel/intern/CCGSubSurf_inline.h
@@ -142,8 +142,7 @@ BLI_INLINE float *ccg_face_getIFNo(
BLI_INLINE int ccg_face_getVertIndex(CCGFace *f, CCGVert *v)
{
- int i;
- for (i = 0; i < f->numVerts; i++) {
+ for (int i = 0; i < f->numVerts; i++) {
if (FACE_getVerts(f)[i] == v) {
return i;
}
@@ -153,8 +152,7 @@ BLI_INLINE int ccg_face_getVertIndex(CCGFace *f, CCGVert *v)
BLI_INLINE int ccg_face_getEdgeIndex(CCGFace *f, CCGEdge *e)
{
- int i;
- for (i = 0; i < f->numVerts; i++) {
+ for (int i = 0; i < f->numVerts; i++) {
if (FACE_getEdges(f)[i] == e) {
return i;
}
@@ -215,8 +213,7 @@ BLI_INLINE void Normalize(float no[3])
BLI_INLINE bool VertDataEqual(const float a[], co
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list