From e637a95d438fbaaef201a1c7b0f8280e1fffc029 Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Tue, 7 Nov 2017 08:28:46 -0500 Subject: [PATCH] switched glyph cache from a map to a hashtable --- docs/Draw.Cursor.html | 4 ++-- docs/X11.html | 14 +++++++++----- docs/index.html | 4 +++- docs/index_modules.html | 4 +++- docs/index_values.html | 4 +++- docs/type_Draw.Cursor.html | 4 ++-- lib/x11.ml | 6 +++--- 7 files changed, 25 insertions(+), 15 deletions(-) diff --git a/docs/Draw.Cursor.html b/docs/Draw.Cursor.html index 38ece7b..d2fe5f0 100644 --- a/docs/Draw.Cursor.html +++ b/docs/Draw.Cursor.html @@ -79,5 +79,5 @@
val has_next_line : t -> bool
val draw_tab : t -> unit
val place_glyph : t -> X11.glyph -> unit
-
val draw_glyph : t -> X11.GlyphMap.key -> unit
-
val next_glyph : t -> X11.GlyphMap.key -> bool
\ No newline at end of file +
val draw_glyph : t -> int -> unit
+
val next_glyph : t -> int -> bool
\ No newline at end of file diff --git a/docs/X11.html b/docs/X11.html index 2697929..130a69d 100644 --- a/docs/X11.html +++ b/docs/X11.html @@ -27,7 +27,9 @@

Module X11

-
module X11: sig .. end

+
module X11: sig .. end
+
+
type xatom 
@@ -471,10 +473,12 @@
val font_load : string -> font
val font_glyph : font -> int -> glyph
val draw_glyph : int -> glyph -> int * int -> int
-
val glyph_cache : glyph GlyphMap.t Pervasives.ref
-
val cache_update : GlyphMap.key -> glyph -> glyph
-
val get_glyph : font -> GlyphMap.key -> glyph
-
val draw_rune : font -> int -> GlyphMap.key -> int * int -> int
+
val glyph_cache : (int, glyph) Hashtbl.t
+
+ +
val cache_update : int -> glyph -> glyph
+
val get_glyph : font -> int -> glyph
+
val draw_rune : font -> int -> int -> int * int -> int
val draw_char : font -> int -> char -> int * int -> int
val draw_stringi : font -> int -> string -> int * int -> int -> unit
val draw_string : font -> int -> string -> int * int -> unit
diff --git a/docs/index.html b/docs/index.html index 995df80..316de90 100644 --- a/docs/index.html +++ b/docs/index.html @@ -28,7 +28,9 @@

- + diff --git a/docs/index_modules.html b/docs/index_modules.html index f7ab3ae..1cb5199 100644 --- a/docs/index_modules.html +++ b/docs/index_modules.html @@ -54,7 +54,9 @@ - +
Misc
X11
X11
+
+
Cfg
Rope
Buf

X
X11
+
+
\ No newline at end of file diff --git a/docs/index_values.html b/docs/index_values.html index 4ad4994..527dc7e 100644 --- a/docs/index_values.html +++ b/docs/index_values.html @@ -134,7 +134,9 @@ gets [Rope] glyph_cache [X11] - +
+
+ glyph_width [Draw] goto [Buf.Cursor] diff --git a/docs/type_Draw.Cursor.html b/docs/type_Draw.Cursor.html index da3868f..060e514 100644 --- a/docs/type_Draw.Cursor.html +++ b/docs/type_Draw.Cursor.html @@ -32,6 +32,6 @@   val has_next_line : Draw.Cursor.t -> bool
  val draw_tab : Draw.Cursor.t -> unit
  val place_glyph : Draw.Cursor.t -> X11.glyph -> unit
-  val draw_glyph : Draw.Cursor.t -> X11.GlyphMap.key -> unit
-  val next_glyph : Draw.Cursor.t -> X11.GlyphMap.key -> bool
+  val draw_glyph : Draw.Cursor.t -> int -> unit
+  val next_glyph : Draw.Cursor.t -> int -> bool
end \ No newline at end of file diff --git a/lib/x11.ml b/lib/x11.ml index f7c4281..5893d84 100644 --- a/lib/x11.ml +++ b/lib/x11.ml @@ -109,15 +109,15 @@ external font_glyph : font -> int -> glyph external draw_glyph : int -> glyph -> (int * int) -> int = "x11_draw_glyph" -let glyph_cache = ref GlyphMap.empty +let glyph_cache = Hashtbl.create 127 let cache_update rune glyph = - glyph_cache := GlyphMap.add rune glyph !glyph_cache; + Hashtbl.replace glyph_cache rune glyph; glyph let get_glyph (font : font) rune = try - let glyph = GlyphMap.find rune !glyph_cache in + let glyph = Hashtbl.find glyph_cache rune in if (glyph.font != font.font) then cache_update rune glyph else -- 2.52.0