forked from enlightenment/efl
elm entry - tune appending to be faster
this is not perfect, but it tuned things to take less time overall but can be a bit more jerky given massive amounts of text like warandpeace, but it takes less time to finish an append cycle in the background for sure. (loading up war and peace goes from 42sec in the background spinning appending to 3sec in an entry on my overpowered box). on my oldest x86 box i have sitting here it goes from 95sec to 10sec.
This commit is contained in:
parent
b2f61deb37
commit
f63f270a85
|
@ -31,7 +31,8 @@
|
||||||
* FIXME: This size is arbitrary, should probably choose a better size.
|
* FIXME: This size is arbitrary, should probably choose a better size.
|
||||||
* Possibly also find a way to set it to a low value for weak computers,
|
* Possibly also find a way to set it to a low value for weak computers,
|
||||||
* and to a big value for better computers. */
|
* and to a big value for better computers. */
|
||||||
#define ELM_ENTRY_CHUNK_SIZE 10000
|
#define ELM_ENTRY_CHUNK_SIZE 100000
|
||||||
|
#define ELM_ENTRY_CHUNK_SIZE_MAX 1000000
|
||||||
#define ELM_ENTRY_DELAY_WRITE_TIME 2.0
|
#define ELM_ENTRY_DELAY_WRITE_TIME 2.0
|
||||||
|
|
||||||
#define ELM_PRIV_ENTRY_SIGNALS(cmd) \
|
#define ELM_PRIV_ENTRY_SIGNALS(cmd) \
|
||||||
|
@ -2982,12 +2983,18 @@ _markup_filter_cb(void *data,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_append_wakeup_job_cb(void *data EINA_UNUSED)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/* This function is used to insert text by chunks in jobs */
|
/* This function is used to insert text by chunks in jobs */
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
_text_append_idler(void *data)
|
_text_append_idler(void *data)
|
||||||
{
|
{
|
||||||
int start;
|
int start;
|
||||||
char backup;
|
char backup;
|
||||||
|
double t, tnow;
|
||||||
Evas_Object *obj = (Evas_Object *)data;
|
Evas_Object *obj = (Evas_Object *)data;
|
||||||
|
|
||||||
ELM_ENTRY_DATA_GET(obj, sd);
|
ELM_ENTRY_DATA_GET(obj, sd);
|
||||||
|
@ -2998,7 +3005,13 @@ _text_append_idler(void *data)
|
||||||
sd->changed = EINA_TRUE;
|
sd->changed = EINA_TRUE;
|
||||||
|
|
||||||
start = sd->append_text_position;
|
start = sd->append_text_position;
|
||||||
if ((start + ELM_ENTRY_CHUNK_SIZE) < sd->append_text_len)
|
if (sd->append_text_chunk <= 0)
|
||||||
|
{
|
||||||
|
sd->append_text_chunk = ELM_ENTRY_CHUNK_SIZE;
|
||||||
|
sd->append_text_last_time = ecore_time_get();
|
||||||
|
}
|
||||||
|
t = sd->append_text_last_time;
|
||||||
|
if ((start + sd->append_text_chunk) < sd->append_text_len)
|
||||||
{
|
{
|
||||||
int pos = start;
|
int pos = start;
|
||||||
int tag_start, esc_start;
|
int tag_start, esc_start;
|
||||||
|
@ -3057,6 +3070,30 @@ _text_append_idler(void *data)
|
||||||
evas_event_thaw_eval(evas_object_evas_get(obj));
|
evas_event_thaw_eval(evas_object_evas_get(obj));
|
||||||
|
|
||||||
_elm_entry_guide_update(obj, EINA_TRUE);
|
_elm_entry_guide_update(obj, EINA_TRUE);
|
||||||
|
tnow = ecore_time_get();
|
||||||
|
t = tnow - sd->append_text_last_time;
|
||||||
|
sd->append_text_last_time = tnow;
|
||||||
|
// for debugging/tuning
|
||||||
|
// printf("append %i in %1.5f\n", sd->append_text_chunk, t);
|
||||||
|
if (t > 0.0)
|
||||||
|
{
|
||||||
|
const double maxtime = 1.0 / 5.0;
|
||||||
|
int new_size;
|
||||||
|
|
||||||
|
if (t > (maxtime / 1000.0))
|
||||||
|
{
|
||||||
|
new_size = ((double)sd->append_text_chunk * maxtime) / t;
|
||||||
|
if (new_size > ELM_ENTRY_CHUNK_SIZE_MAX)
|
||||||
|
new_size = ELM_ENTRY_CHUNK_SIZE_MAX;
|
||||||
|
else if (new_size < ELM_ENTRY_CHUNK_SIZE)
|
||||||
|
new_size = ELM_ENTRY_CHUNK_SIZE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
new_size = ELM_ENTRY_CHUNK_SIZE_MAX;
|
||||||
|
|
||||||
|
sd->append_text_chunk = new_size;
|
||||||
|
}
|
||||||
|
ecore_job_add(_append_wakeup_job_cb, NULL);
|
||||||
|
|
||||||
/* If there's still more to go, renew the idler, else, cleanup */
|
/* If there's still more to go, renew the idler, else, cleanup */
|
||||||
if (sd->append_text_position < sd->append_text_len)
|
if (sd->append_text_position < sd->append_text_len)
|
||||||
|
@ -3065,8 +3102,9 @@ _text_append_idler(void *data)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
sd->append_text_chunk = 0;
|
||||||
edje_object_part_text_cursor_pos_set(sd->entry_edje, "elm.text",
|
edje_object_part_text_cursor_pos_set(sd->entry_edje, "elm.text",
|
||||||
EDJE_CURSOR_MAIN, sd->cursor_pos);
|
EDJE_CURSOR_MAIN, sd->cursor_pos);
|
||||||
free(sd->append_text_left);
|
free(sd->append_text_left);
|
||||||
sd->append_text_left = NULL;
|
sd->append_text_left = NULL;
|
||||||
sd->append_text_idler = NULL;
|
sd->append_text_idler = NULL;
|
||||||
|
|
|
@ -47,6 +47,8 @@ struct _Elm_Entry_Data
|
||||||
char *prediction_hint;
|
char *prediction_hint;
|
||||||
int append_text_position;
|
int append_text_position;
|
||||||
int append_text_len;
|
int append_text_len;
|
||||||
|
int append_text_chunk;
|
||||||
|
double append_text_last_time;
|
||||||
/* Only for clipboard */
|
/* Only for clipboard */
|
||||||
const char *cut_sel;
|
const char *cut_sel;
|
||||||
const char *text;
|
const char *text;
|
||||||
|
|
Loading…
Reference in New Issue