Changeset 12554


Ignore:
Timestamp:
Aug 8, 2009, 3:41:23 AM (10 years ago)
Author:
rme
Message:

Use a buffer-string-cache.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/cocoa-ide/hemlock-text.lisp

    r12546 r12554  
    5656
    5757(objc:defmethod (#/length #>NSUInteger) ((self xhemlock-buffer-string))
     58  (let* ((cache (hemlock-buffer-string-cache self)))
     59    (or (buffer-cache-buflen cache)
     60        (setf (buffer-cache-buflen cache)
     61              (let* ((buffer (buffer-cache-buffer cache)))
     62                (hemlock-buffer-length buffer))))))
     63
     64#+slow
     65(objc:defmethod (#/length #>NSUInteger) ((self xhemlock-buffer-string))
    5866  (let* ((buffer (hemlock-buffer self))
    5967         (hi::*current-buffer* buffer))
    6068    (hi:count-characters (hi:buffer-region buffer))))
    6169
     70(objc:defmethod (#/characterAtIndex: :unichar) ((self xhemlock-buffer-string)
     71                                                (index #>NSUInteger))
     72  (char-code (hemlock-char-at-index (hemlock-buffer-string-cache self) index)))
     73
     74#+slow
    6275(objc:defmethod (#/characterAtIndex: :unichar) ((self xhemlock-buffer-string) (index #>NSUInteger))
    6376  (let* ((buffer (hemlock-buffer self))
     
    193206       (#/prepareWithInvocationTarget: undo-mgr self)
    194207       (ns:make-ns-range pos n) #@"")))
     208  (let ((cache (hemlock-buffer-string-cache (hemlock-string self))))
     209    (adjust-buffer-cache-for-insertion cache pos n)
     210    (update-line-cache-for-index cache pos))
    195211  (unless *suppress-edit-notifications*
    196212    (textstorage-note-insertion-at-position self pos n)))
     
    200216     (extra :<NSI>nteger))
    201217  (declare (ignorable extra))
     218  (let ((cache (hemlock-buffer-string-cache (hemlock-string self))))
     219    (reset-buffer-cache cache)
     220    (update-line-cache-for-index cache pos))
    202221  (unless *suppress-edit-notifications*
    203222    (ns:with-ns-range (range pos n)
Note: See TracChangeset for help on using the changeset viewer.