1111// =======
1212
1313struct d_lineHit_s {
14- char * source;
15- char * name;
14+ char * source;
15+ char * name;
1616 int line;
1717 int count;
1818};
1919
2020struct d_callHit_s {
21- char * source;
22- char * name;
21+ char * source;
22+ char * name;
2323 int count;
2424 int lineHitNum;
2525 int lineHitSz;
@@ -30,11 +30,11 @@ struct d_callHit_s {
3030// ui_IDebug Interface
3131// ===================
3232
33- class ui_debug_c : public ui_IDebug , public thread_c {
33+ class ui_debug_c : public ui_IDebug , public thread_c {
3434public:
3535 // Interface
36- void SetProfiling (bool enable);
37- void ToggleProfiling ();
36+ void SetProfiling (bool enable) override ;
37+ void ToggleProfiling () override ;
3838
3939 // Encapsulated
4040 ui_debug_c (ui_main_c* ui);
@@ -119,7 +119,7 @@ static ui_debug_c* GetDebugPtr(lua_State* L)
119119 return (ui_debug_c*)ui->debug ;
120120}
121121
122- static void debugHook (lua_State* L, lua_Debug * ar)
122+ static void debugHook (lua_State* L, lua_Debug* ar)
123123{
124124 ui_debug_c* d = GetDebugPtr (L);
125125 d->hookHolding = true ;
@@ -133,8 +133,9 @@ static int lineComp(const void* aVoid, const void* bVoid)
133133 d_lineHit_s* b = (d_lineHit_s*)bVoid;
134134 if (a->count == b->count ) {
135135 return 0 ;
136- } else {
137- return a->count > b->count ? -1 : 1 ;
136+ }
137+ else {
138+ return a->count > b->count ? -1 : 1 ;
138139 }
139140}
140141
@@ -144,8 +145,9 @@ static int callComp(const void* aVoid, const void* bVoid)
144145 d_callHit_s* b = (d_callHit_s*)bVoid;
145146 if (a->count == b->count ) {
146147 return 0 ;
147- } else {
148- return a->count > b->count ? -1 : 1 ;
148+ }
149+ else {
150+ return a->count > b->count ? -1 : 1 ;
149151 }
150152}
151153
@@ -156,14 +158,14 @@ void ui_debug_c::ThreadProc()
156158 ui->sys ->Sleep (1 );
157159
158160 if (profiling) {
159- if ( !ui->inLua ) {
161+ if (!ui->inLua ) {
160162 continue ;
161163 }
162164 hookHold = true ;
163165 lua_sethook (ui->L , &debugHook, LUA_MASKLINE , 0 );
164166 while (profiling && !hookHolding);
165167 lua_sethook (ui->L , &debugHook, 0 , 0 );
166- if ( !profiling ) {
168+ if (!profiling) {
167169 hookHold = false ;
168170 continue ;
169171 }
@@ -182,7 +184,7 @@ void ui_debug_c::ThreadProc()
182184 }
183185 if (l == lineHitNum) {
184186 if (lineHitNum == lineHitSz) {
185- lineHitSz<<= 1 ;
187+ lineHitSz <<= 1 ;
186188 trealloc (lineHits, lineHitSz);
187189 }
188190 lineHits[l].source = AllocString (dbg.source );
@@ -196,14 +198,14 @@ void ui_debug_c::ThreadProc()
196198 if (funcName && lua_getstack (ui->L , 1 , &dbg) && lua_getinfo (ui->L , " Sln" , &dbg) && dbg.source ) {
197199 int c;
198200 for (c = 0 ; c < callHitNum; c++) {
199- if ( !strcmp (funcSource, callHits[c].source ) && !strcmp (funcName, callHits[c].name ) ) {
201+ if (!strcmp (funcSource, callHits[c].source ) && !strcmp (funcName, callHits[c].name )) {
200202 callHits[c].count ++;
201203 break ;
202204 }
203205 }
204206 if (c == callHitNum) {
205207 if (callHitNum == callHitSz) {
206- callHitSz<<= 1 ;
208+ callHitSz <<= 1 ;
207209 trealloc (callHits, callHitSz);
208210 }
209211 if (callHitNum == callHitInitCount) {
@@ -230,7 +232,7 @@ void ui_debug_c::ThreadProc()
230232 }
231233 if (l == call->lineHitNum ) {
232234 if (call->lineHitNum == call->lineHitSz ) {
233- call->lineHitSz <<= 1 ;
235+ call->lineHitSz <<= 1 ;
234236 trealloc (call->lineHits , call->lineHitSz );
235237 }
236238 call->lineHits [l].source = AllocString (dbg.source );
@@ -243,12 +245,13 @@ void ui_debug_c::ThreadProc()
243245 }
244246 hookHold = false ;
245247 while (hookHolding);
246- } else if (lineHitNum) {
248+ }
249+ else if (lineHitNum) {
247250 ui->sys ->con ->Printf (" Hot lines:\n " );
248251 qsort (lineHits, lineHitNum, sizeof (d_lineHit_s), lineComp);
249252 for (int l = 0 ; l < lineHitNum; l++) {
250253 if (l < 20 ) {
251- ui->sys ->con ->Printf (" %s(%d) in '%s': %d\n " , lineHits[l].source , lineHits[l].line , lineHits[l].name ? lineHits[l].name : " ?" , lineHits[l].count );
254+ ui->sys ->con ->Printf (" %s(%d) in '%s': %d\n " , lineHits[l].source , lineHits[l].line , lineHits[l].name ? lineHits[l].name : " ?" , lineHits[l].count );
252255 }
253256 delete lineHits[l].source ;
254257 delete lineHits[l].name ;
@@ -263,7 +266,7 @@ void ui_debug_c::ThreadProc()
263266 }
264267 for (int l = 0 ; l < callHits[c].lineHitNum ; l++) {
265268 if (c < 10 && l < 5 ) {
266- ui->sys ->con ->Printf (" \t %s(%d) in '%s': %d\n " , callHits[c].lineHits [l].source , callHits[c].lineHits [l].line , callHits[c].lineHits [l].name ? callHits[c].lineHits [l].name : " ?" , callHits[c].lineHits [l].count );
269+ ui->sys ->con ->Printf (" \t %s(%d) in '%s': %d\n " , callHits[c].lineHits [l].source , callHits[c].lineHits [l].line , callHits[c].lineHits [l].name ? callHits[c].lineHits [l].name : " ?" , callHits[c].lineHits [l].count );
267270 }
268271 delete callHits[c].lineHits [l].source ;
269272 delete callHits[c].lineHits [l].name ;
@@ -282,7 +285,8 @@ void ui_debug_c::SetProfiling(bool enable)
282285 if (enable) {
283286 ui->sys ->con ->Printf (" Profiling enabled.\n " );
284287 profiling = true ;
285- } else {
288+ }
289+ else {
286290 ui->sys ->con ->Printf (" Profiling finished:\n " );
287291 profiling = false ;
288292 while (lineHitNum || callHitNum);
@@ -291,5 +295,5 @@ void ui_debug_c::SetProfiling(bool enable)
291295
292296void ui_debug_c::ToggleProfiling ()
293297{
294- SetProfiling ( !profiling );
295- }
298+ SetProfiling (!profiling);
299+ }
0 commit comments