projects
/
brisk.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
843082d
)
add table cache for table_content method
wr-on-ws
author
Matteo Nastasi
<nastasi@alternativeoutput.it>
Thu, 16 Apr 2020 16:15:30 +0000
(18:15 +0200)
committer
Matteo Nastasi
<nastasi@alternativeoutput.it>
Thu, 16 Apr 2020 16:25:05 +0000
(18:25 +0200)
web/Obj/brisk.phh
patch
|
blob
|
history
diff --git
a/web/Obj/brisk.phh
b/web/Obj/brisk.phh
index
affe74a
..
7f5d437
100644
(file)
--- a/
web/Obj/brisk.phh
+++ b/
web/Obj/brisk.phh
@@
-657,6
+657,8
@@
class Table {
var $wakeup_time;
var $wakeup_time;
+ var $cache;
+
function Table()
{
}
function Table()
{
}
@@
-688,6
+690,8
@@
class Table {
$thiz->wakeup_time = 0;
$thiz->wakeup_time = 0;
+ $thiz->cache = NULL;
+
return ($thiz);
}
return ($thiz);
}
@@
-711,6
+715,8
@@
class Table {
$this->table_start = $from->table_start;
$this->wakeup_time = $from->wakeup_time;
$this->table_start = $from->table_start;
$this->wakeup_time = $from->wakeup_time;
+
+ $this->cache = $from->cache;
}
function myclone($from)
}
function myclone($from)
@@
-745,6
+751,8
@@
class Table {
$thiz->wakeup_time = $from->wakeup_time;
$thiz->wakeup_time = $from->wakeup_time;
+ $thiz->cache = $from->cache;
+
return ($thiz);
}
return ($thiz);
}
@@
-1454,7
+1462,7
@@
class Brisk
for ($i = 0 ; $i < TABLES_N ; $i++) {
for ($i = 0 ; $i < TABLES_N ; $i++) {
- $ret .= $this->table_content($user, $i);
+ $ret .= $this->table_content($user, $i
, TRUE
);
$ret .= $this->table[$i]->act_content($user);
if ($this->table[$i]->wag_own != -1)
$ret .= $this->table[$i]->act_content($user);
if ($this->table[$i]->wag_own != -1)
@@
-2712,7
+2720,7
@@
class Brisk
return ($content);
}
return ($content);
}
- function table_content($user, $table_idx)
+ function table_content($user, $table_idx
, $use_cache=FALSE
)
{
$content = "";
$ret = "";
{
$content = "";
$ret = "";
@@
-2724,10
+2732,25
@@
class Brisk
$sess = $user->sess;
$table = $this->table[$table_idx];
$sess = $user->sess;
$table = $this->table[$table_idx];
+ $user_at_table = FALSE;
+
if ($user->stat != 'room')
return;
$user_cur_id = $user->idx_get();
if ($user->stat != 'room')
return;
$user_cur_id = $user->idx_get();
+
+ # check if user at table
+ for ($i = 0 ; $i < $table->player_n ; $i++) {
+ if ($user_cur_id == $table->player[$i]) {
+ $user_at_table = TRUE;
+ break;
+ }
+ }
+
+ if ($use_cache && !$user_at_table && $table->cache != NULL) {
+ return $table->cache;
+ }
+
$content = "[ ";
for ($i = 0 ; $i < $table->player_n ; $i++) {
$user_cur = $this->user[$table->player[$i]];
$content = "[ ";
for ($i = 0 ; $i < $table->player_n ; $i++) {
$user_cur = $this->user[$table->player[$i]];
@@
-2750,7
+2773,9
@@
class Brisk
$content .= ' ]';
$ret .= sprintf('j_tab_cont(%d, %s);', $table_idx, $content);
$content .= ' ]';
$ret .= sprintf('j_tab_cont(%d, %s);', $table_idx, $content);
-
+ if (! $user_at_table) {
+ $table->cache = $ret;
+ }
return ($ret);
}
return ($ret);
}