From 4a17a5b58fa863811b2377d0553d59471b244d44 Mon Sep 17 00:00:00 2001 From: Russ Ross Date: Mon, 30 May 2011 14:42:38 -0600 Subject: [PATCH] remove dependency on less function --- inline.go | 2 +- markdown.go | 28 ---------------------------- 2 files changed, 1 insertion(+), 29 deletions(-) diff --git a/inline.go b/inline.go index f6043ca..aa12202 100644 --- a/inline.go +++ b/inline.go @@ -634,7 +634,7 @@ func isSafeLink(link []byte) bool { for _, prefix := range validUris { // TODO: handle unicode here // case-insensitive prefix test - if len(link) > len(prefix) && !less(link[:len(prefix)], prefix) && !less(prefix, link[:len(prefix)]) && isalnum(link[len(prefix)]) { + if len(link) > len(prefix) && bytes.Equal(bytes.ToLower(link[:len(prefix)]), prefix) && isalnum(link[len(prefix)]) { return true } } diff --git a/markdown.go b/markdown.go index 2276ed9..99dc335 100644 --- a/markdown.go +++ b/markdown.go @@ -14,7 +14,6 @@ package blackfriday import ( "bytes" - "unicode" ) // These are the supported markdown parsing extensions. @@ -275,33 +274,6 @@ type reference struct { title []byte } -// Compare two []byte values (case-insensitive), returning -// true if a is less than b. -func less(a []byte, b []byte) bool { - // adapted from bytes.Compare in stdlib - m := len(a) - if m > len(b) { - m = len(b) - } - for i, ac := range a[0:m] { - // do a case-insensitive comparison - ai, bi := unicode.ToLower(int(ac)), unicode.ToLower(int(b[i])) - switch { - case ai > bi: - return false - case ai < bi: - return true - } - } - switch { - case len(a) < len(b): - return true - case len(a) > len(b): - return false - } - return false -} - // Check whether or not data starts with a reference link. // If so, it is parsed and stored in the list of references // (in the render struct).