OSDN Git Service

Another approach for #3: cancel profiling in OTR
[luatex-ja/luatexja.git] / src / ltj-lineskip.lua
index 010e4df..a2de191 100644 (file)
@@ -11,8 +11,6 @@ local ltjl = luatexja.lineskip
 local id_glue    = node.id 'glue'
 local id_penalty = node.id 'penalty'
 local id_hlist   = node.id 'hlist'
-local setfield = node.direct.setfield
-local getfield = node.direct.getfield
 local getlist = node.direct.getlist
 local node_new = node.direct.new
 local node_prev = node.direct.getprev
@@ -24,7 +22,7 @@ local getheight = node.direct.getheight
 local texget = tex.get
 
 local node_getglue = node.getglue
-local setglue = luatexja.setglue
+local setglue = node.direct.setglue
 local setsubtype = node.direct.setsubtype
 local function copy_glue (new_glue, old_glue_name, subtype, new_w)
    setsubtype(new_glue, subtype)
@@ -51,6 +49,19 @@ function ltjl.setting(profiler, skip_method)
 end
 
 do
+    local backup
+    function ltjl.setting_backup()
+        backup = { ltj_profiler, ltj_skip }
+        ltj_profiler, ltj_skip = ltjl.p_dummy, ltjl.l_dummy
+    end
+    function ltjl.setting_restore()
+        if backup then
+            ltj_profiler, ltj_skip, backup = backup[1], backup[2], nil
+        end
+    end
+end
+
+do
 local traverse_id = node.direct.traverse_id
 local function adjust_glue(nh)
    local h = to_direct(nh)
@@ -61,7 +72,7 @@ local function adjust_glue(nh)
         local p, n = node_prev(x), node_next(x)
         if p then
         local pid = getid(p)
-           while (id_glue<=pid) and (pid<=id_penalty) and node_prev(p) do 
+           while (id_glue<=pid) and (pid<=id_penalty) and node_prev(p) do
              p = node_prev(p); pid = getid(p)
            end
            if pid==id_hlist and getid(n)==id_hlist then
@@ -87,7 +98,7 @@ local getnest = tex.getnest
 
 local function dir_adjust_append_vlist(b, loc, prev, mirrored)
    local old_b = to_direct(b)
-   local new_b = loc=='box' and 
+   local new_b = loc=='box' and
       make_dir_whatsit(old_b, old_b, get_dir_count(), 'append_vlist') or old_b
    local _, ht, dp = getwhd(new_b)
    if prev > -65536000 then
@@ -102,7 +113,7 @@ local function dir_adjust_append_vlist(b, loc, prev, mirrored)
       end
       if tail then
          if getid(tail)==id_hlist and getid(new_b)==id_hlist then
-            if getdepth(tail)==prev then 
+            if getdepth(tail)==prev then
                lmin, adj = ltj_profiler(tail, new_b, mirrored, bw)
             end
          end