- Subject: Re: updated ffx -- file dialog
- From: "Klaus Schmid" <klaus.schmid@xxxxxx>
- Date: Fri, 20 Jun 2003 14:49:52 +0200
"Günter Milde" <milde@xxxxxxxxxxxxxxxxxxxx> wrote:
> So here comes my idea:
>
> custom_var recent_sync_level
>       0 do not sync
>       1 synchronize at minimum (startup, exit)
>       2 synchronize normally (startup, popu-menu-function, exit)
>
> I still prefer to go without a buffer by saving the last access
> time to a variable when reading the file to a list. This way
> file_changed_on_disk could be replaced with a list_changed_on_disk
function.
Thanks for this pointer. I tested stat_file with st.st_mtime and it seems to
work flawlessly.
So the buffer seems redundant, and it should be smaller and faster with this
lower level i/o.
Updated pseudo code:
actions at different places
    before startup
        set current list to zero-length
    at startup
        get buffer_file_strings
        if buffer_file_strings
            merge buffer_file_strings
            if sync_medium_or_gt
                read file_list
                merge file_list
                write file
    before file_dialog
        if sync_low_or_gt and new_file_to_read
            read file_list
            merge file_list
            if sync_high
                write file
    after file_dialog
        if strings_to_save
            merge strings_to_save
            if sync_medium_or_gt and new_file_to_read
                read file_list
                merge file_list
                write file
    on exit
        if sync_low_or_gt and merged_but_not_written
            if new_file_to_read
                read file_list
                merge file_list
            write file
terminology:
    file:          file in which file strings are saved
    file_list:     list of file strings from file
    merge xxx:     merge xxx to current list
    write file:    write list to file
I will think about the time issue. For now I think it would
be useful mainly for low sync. with less overhead at other places.
Here an updated version of merge (both lists might be unsorted and
contain doubles; it makes other recall-stack functions redundant)
It assumes 8 chars for _time() in hex format appended to each string.
static define merge( a1, a2) %                                         %{{{
{
   variable x, i, a, b, c;
   % normal map: [:-9] [-8:]
   % swapped:    [:7]  [8:]
   % remove doubles, keep latest
   a= [ a1, a2];
   a= a[array_sort(a)];
   x= Integer_Type[length(a)]; x[*]= 1;
   b= a[-1][[:-9]];
   for (i=2;i<=length(a);i++)
     {
        c= a[-i][[:-9]];
        if ( c == b)
          x[-i]= 0;
        else
          b= c;
     }
   a= a[where(x)];
   % sort by time stamp
   x= String_Type[length(a)];
   for (i=0;i<length(a);i++)
     x[i]= a[i][[-8:]];
   return a[array_sort(x)];
}
-- Klaus
--------------------------
To unsubscribe send email to <jed-users-request@xxxxxxxxxxx> with
the word "unsubscribe" in the message body.
Need help? Email <jed-users-owner@xxxxxxxxxxx>.
  [2003 date index]
  [2003 thread index]
  
  [Thread Prev] [Thread Next]
      
  [Date Prev] [Date Next]