Skip to content

Commit 982d83e

Browse files
committed
COMMON: revert minor changes for performance
1 parent dfabea0 commit 982d83e

File tree

13 files changed

+41
-72
lines changed

13 files changed

+41
-72
lines changed

ChangeLog

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
2016-04-26 (0.12.6)
2-
Added LASTX, LASTY system variables
1+
2016-05-07 (0.12.6)
2+
Reverted LASTX/LASTY. Data was already accessible via POINT command
3+
Reverted getPixel from SCREEN for performance. Can still access this by passed -ve x/y values
4+
Reverted using var V_FUNC handling for int sys vars due to eval issues
35

46
2016-04-26 (0.12.6)
57
Fixes for unit case sensitivity

src/common/blib.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,7 @@ void cmd_deriv(void);
9292
void cmd_diffeq(void);
9393

9494
// not basic, but speed is needed
95-
void graph_reset(void); // graphics module - reset
96-
void graph_get_xstep(var_t *r);
97-
void graph_get_ystep(var_t *r);
98-
void graph_get_mx(var_t *r);
99-
void graph_get_my(var_t *r);
95+
void graph_reset(void);
10096
void cmd_pset(void);
10197
void cmd_line(void);
10298
void cmd_rect(void);

src/common/blib_func.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2354,7 +2354,7 @@ void cmd_genfunc(long funcCode, var_t *r) {
23542354
err_argerr();
23552355
else {
23562356
x = v_getint(v_elem(v, 0));
2357-
y = v_getint(v_elem(v, 0));
2357+
y = v_getint(v_elem(v, 1));
23582358
}
23592359
} else {
23602360
x = v_getint(v);

src/common/blib_graph.c

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,6 @@ void graph_reset() {
1818
gra_x = gra_y = 0;
1919
}
2020

21-
void graph_get_xstep(var_t *r) {
22-
v_setint(r, gra_x);
23-
}
24-
25-
void graph_get_ystep(var_t *r) {
26-
v_setint(r, gra_y);
27-
}
28-
29-
void graph_get_mx(var_t *r) {
30-
v_setint(r, os_graf_mx - 1);
31-
}
32-
33-
void graph_get_my(var_t *r) {
34-
v_setint(r, os_graf_my - 1);
35-
}
36-
3721
//
3822
// VIEW [x1,y1,x2,y2[,c[,b]]]
3923
//

src/common/brun.c

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -219,26 +219,6 @@ void setsysvar_int(int index, var_int_t value) {
219219
activate_task(tid);
220220
}
221221

222-
/**
223-
* sets the value of an callback system-variable
224-
*/
225-
void setsysvar_fn(int index, method value) {
226-
int tid;
227-
int i;
228-
229-
tid = ctask->tid;
230-
for (i = 0; i < count_tasks(); i++) {
231-
activate_task(i);
232-
if (ctask->has_sysvars) {
233-
var_t *var_p = tvar[index];
234-
var_p->type = V_FUNC;
235-
var_p->const_flag = 1;
236-
var_p->v.fn.cb = value;
237-
}
238-
}
239-
activate_task(tid);
240-
}
241-
242222
/**
243223
* sets the value of a real system-variable
244224
*/
@@ -287,10 +267,6 @@ void setsysvar_str(int index, const char *value) {
287267
activate_task(tid);
288268
}
289269

290-
void sysvar_getcwd(var_t *r) {
291-
v_setstr(r, dev_getcwd());
292-
}
293-
294270
/**
295271
* create predefined system variables for this task
296272
*/
@@ -302,14 +278,12 @@ void exec_setup_predefined_variables() {
302278
ctask->has_sysvars = 1;
303279
setsysvar_str(SYSVAR_SBVER, SB_STR_VER);
304280
setsysvar_num(SYSVAR_PI, SB_PI);
281+
setsysvar_int(SYSVAR_XMAX, os_graf_mx - 1);
282+
setsysvar_int(SYSVAR_YMAX, os_graf_my - 1);
305283
setsysvar_int(SYSVAR_TRUE, 1);
306284
setsysvar_int(SYSVAR_FALSE, 0);
285+
setsysvar_str(SYSVAR_CWD, dev_getcwd());
307286
setsysvar_str(SYSVAR_COMMAND, opt_command);
308-
setsysvar_fn(SYSVAR_CWD, sysvar_getcwd);
309-
setsysvar_fn(SYSVAR_XMAX, graph_get_mx);
310-
setsysvar_fn(SYSVAR_YMAX, graph_get_my);
311-
setsysvar_fn(SYSVAR_LASTX, graph_get_xstep);
312-
setsysvar_fn(SYSVAR_LASTY, graph_get_ystep);
313287

314288
#if defined(_UnixOS)
315289
if (dev_getenv("HOME")) {
@@ -329,7 +303,7 @@ void exec_setup_predefined_variables() {
329303
strcpy(homedir, dev_getenv("HOME"));
330304
}
331305
else {
332-
GetModuleFileName(NULL, homedir, 1024);
306+
GetModuleFileName(NULL, homedir, sizeof(homedir) - 1);
333307
char *p = strrchr(homedir, '\\');
334308
*p = '\0';
335309
strcat(homedir, "\\");

src/common/file.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,7 @@ void dev_chdir(const char *dir) {
616616
if (chdir(dir) != 0) {
617617
err_file(errno);
618618
}
619+
setsysvar_str(SYSVAR_CWD, dev_getcwd());
619620
}
620621

621622
/**

src/common/scan.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3447,8 +3447,6 @@ void comp_init() {
34473447
comp_var_getID(LCN_SV_X);
34483448
comp_var_getID(LCN_SV_Y);
34493449
comp_var_getID(LCN_SV_Z);
3450-
comp_var_getID(LCN_SV_LASTX);
3451-
comp_var_getID(LCN_SV_LASTY);
34523450
}
34533451

34543452
/*

src/common/var.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@
5454
#define SYSVAR_X 9 /**< system variable, X @ingroup var */
5555
#define SYSVAR_Y 10 /**< system variable, Y @ingroup var */
5656
#define SYSVAR_Z 11 /**< system variable, Z @ingroup var */
57-
#define SYSVAR_LASTX 12 /**< system variable, LASTX @ingroup var */
58-
#define SYSVAR_LASTY 13 /**< system variable, LASTY @ingroup var */
59-
#define SYSVAR_COUNT 14
57+
#define SYSVAR_COUNT 12
6058

6159
/**
6260
* @ingroup var

src/languages/keywords.en.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -492,8 +492,6 @@ struct proc_keyword_s proc_table[] = {
492492
#define LCN_SV_X "X"
493493
#define LCN_SV_Y "Y"
494494
#define LCN_SV_Z "Z"
495-
#define LCN_SV_LASTX "LASTX"
496-
#define LCN_SV_LASTY "LASTY"
497495

498496
// fast cut of comments (pp)
499497
#define LCN_REM_1 ":rem "

src/ui/ansiwidget.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ struct AnsiWidget {
5151
int getColor() { return _back->_fg; }
5252
int getFontSize() { return _fontSize; }
5353
FormInput *getNextField(FormInput *field) { return _back->getNextField(field); }
54+
int getPixel(int x, int y) { return _back->getPixel(x, y); }
5455
int getScreenWidth() { return _back->_width; }
5556
void getScroll(int &x, int &y) { _back->getScroll(x, y); }
5657
int getHeight() { return _height; }

0 commit comments

Comments
 (0)