Skip to content

Commit

Permalink
move some TODOs from diff.go to adaptor.go
Browse files Browse the repository at this point in the history
  • Loading branch information
josharian committed Dec 30, 2019
1 parent 9897735 commit b63e0fa
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
20 changes: 20 additions & 0 deletions adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,23 @@ func (ab *diffSlices) WriteBTo(w io.Writer, i int) (int, error) { return fmt.Fpr
// Then Seek/ReadAt to read each line lazily as needed, relying on the OS page cache for performance.
// This will allow diffing giant files with low memory use, at a significant time cost.
// An alternative is to mmap the files, although this is OS-specific and can be fiddly.

// TODO: consider adding a StringIntern type, something like:
//
// type StringIntern struct {
// s map[string]*string
// }
//
// func (i *StringIntern) Bytes(b []byte) *string
// func (i *StringIntern) String(s string) *string
//
// And document what it is and why to use it.
// And consider adding helper functions to Strings and Bytes to use it.
// The reason to use it is that a lot of the execution time in diffing
// (which is an expensive operation) is taken up doing string comparisons.
// If you have paid the O(n) cost to intern all strings involved in both A and B,
// then string comparisons are reduced to cheap pointer comparisons.

// TODO: consider adding an "it just works" test helper that accepts two slices (via interface{}),
// diffs them using Strings or Bytes or Slices (using reflect.DeepEqual) as appropriate,
// and calls t.Errorf with a generated diff if they're not equal.
20 changes: 0 additions & 20 deletions diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,3 @@ type PairWriterTo interface {
myers.Pair
WriterTo
}

// TODO: consider adding a StringIntern type, something like:
//
// type StringIntern struct {
// s map[string]*string
// }
//
// func (i *StringIntern) Bytes(b []byte) *string
// func (i *StringIntern) String(s string) *string
//
// And document what it is and why to use it.
// And consider adding helper functions to Strings and Bytes to use it.
// The reason to use it is that a lot of the execution time in diffing
// (which is an expensive operation) is taken up doing string comparisons.
// If you have paid the O(n) cost to intern all strings involved in both A and B,
// then string comparisons are reduced to cheap pointer comparisons.

// TODO: consider adding an "it just works" test helper that accepts two slices (via interface{}),
// diffs them using Strings or Bytes or Slices (using reflect.DeepEqual) as appropriate,
// and calls t.Errorf with a generated diff if they're not equal.

0 comments on commit b63e0fa

Please sign in to comment.