[Openmcl-cvs-notifications] r12554 - /trunk/source/cocoa-ide/hemlock-text.lisp

rme at clozure.com rme at clozure.com
Fri Aug 7 23:41:24 EDT 2009


Author: rme
Date: Fri Aug  7 23:41:23 2009
New Revision: 12554

Log:
Use a buffer-string-cache.

Modified:
    trunk/source/cocoa-ide/hemlock-text.lisp

Modified: trunk/source/cocoa-ide/hemlock-text.lisp
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/source/cocoa-ide/hemlock-text.lisp (original)
+++ trunk/source/cocoa-ide/hemlock-text.lisp Fri Aug  7 23:41:23 2009
@@ -55,10 +55,23 @@
 ;;; NSString primitive methods
 =

 (objc:defmethod (#/length #>NSUInteger) ((self xhemlock-buffer-string))
+  (let* ((cache (hemlock-buffer-string-cache self)))
+    (or (buffer-cache-buflen cache)
+        (setf (buffer-cache-buflen cache)
+              (let* ((buffer (buffer-cache-buffer cache)))
+		(hemlock-buffer-length buffer))))))
+
+#+slow
+(objc:defmethod (#/length #>NSUInteger) ((self xhemlock-buffer-string))
   (let* ((buffer (hemlock-buffer self))
 	 (hi::*current-buffer* buffer))
     (hi:count-characters (hi:buffer-region buffer))))
 =

+(objc:defmethod (#/characterAtIndex: :unichar) ((self xhemlock-buffer-stri=
ng)
+						(index #>NSUInteger))
+  (char-code (hemlock-char-at-index (hemlock-buffer-string-cache self) ind=
ex)))
+
+#+slow
 (objc:defmethod (#/characterAtIndex: :unichar) ((self xhemlock-buffer-stri=
ng) (index #>NSUInteger))
   (let* ((buffer (hemlock-buffer self))
          (hi::*current-buffer* buffer)
@@ -191,6 +204,9 @@
       (#/replaceCharactersInRange:withString:
        (#/prepareWithInvocationTarget: undo-mgr self)
        (ns:make-ns-range pos n) #@"")))
+  (let ((cache (hemlock-buffer-string-cache (hemlock-string self))))
+    (adjust-buffer-cache-for-insertion cache pos n)
+    (update-line-cache-for-index cache pos))
   (unless *suppress-edit-notifications*
     (textstorage-note-insertion-at-position self pos n)))
 =

@@ -198,6 +214,9 @@
     ((self xhemlock-text-storage) (pos :<NSI>nteger) (n :<NSI>nteger)
      (extra :<NSI>nteger))
   (declare (ignorable extra))
+  (let ((cache (hemlock-buffer-string-cache (hemlock-string self))))
+    (reset-buffer-cache cache)
+    (update-line-cache-for-index cache pos))
   (unless *suppress-edit-notifications*
     (ns:with-ns-range (range pos n)
       (#/edited:range:changeInLength: self



More information about the Openmcl-cvs-notifications mailing list