FAQ
Since the number of elements are fixed, an array is much more efficient
than a slice.

And FindAllIndex can return a [][2]byte, which is a single object, while
[][]byte is a lot more objects. Since the value has to be escaped, I guess
the compiler cannot optimize it at this point.

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Opennota at Sep 4, 2014 at 1:58 pm
    Arrays can't be nil, that's why, I guess.

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • David DENG at Sep 4, 2014 at 2:28 pm
    If so, an array of [-1, -1] can express the result of not found in FindIndex,
    and zero length of slice can serve for FindAllIndex

    David
    On Thursday, September 4, 2014 6:58:40 AM UTC-7, opennota wrote:

    Arrays can't be nil, that's why, I guess.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Rob Pike at Sep 4, 2014 at 3:40 pm
    Missed opportunity. It's too late now.

    -rob

    On Thu, Sep 4, 2014 at 7:28 AM, David DENG wrote:
    If so, an array of [-1, -1] can express the result of not found in
    FindIndex, and zero length of slice can serve for FindAllIndex

    David
    On Thursday, September 4, 2014 6:58:40 AM UTC-7, opennota wrote:

    Arrays can't be nil, that's why, I guess.
    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Dobrosław Żybort at Sep 4, 2014 at 7:43 pm
    You can always file an issue (to consider for Go2):
    https://code.google.com/p/go/issues/list?q=label:Go2

    W dniu czwartek, 4 września 2014 16:28:39 UTC+2 użytkownik David DENG
    napisał:
    If so, an array of [-1, -1] can express the result of not found in
    FindIndex, and zero length of slice can serve for FindAllIndex

    David
    On Thursday, September 4, 2014 6:58:40 AM UTC-7, opennota wrote:

    Arrays can't be nil, that's why, I guess.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Rob Pike at Sep 4, 2014 at 8:49 pm
    Compared to the other overheads of regular expression engines, this is
    a minor point at best.

    -rob

    On Thu, Sep 4, 2014 at 12:41 PM, Dobrosław Żybort wrote:
    You can always file an issue (to consider for Go2):
    https://code.google.com/p/go/issues/list?q=label:Go2

    W dniu czwartek, 4 września 2014 16:28:39 UTC+2 użytkownik David DENG
    napisał:
    If so, an array of [-1, -1] can express the result of not found in
    FindIndex, and zero length of slice can serve for FindAllIndex

    David
    On Thursday, September 4, 2014 6:58:40 AM UTC-7, opennota wrote:

    Arrays can't be nil, that's why, I guess.
    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Caleb Spare at Sep 4, 2014 at 10:16 pm
    If so, an array of [-1, -1] can express the result of not found in FindIndex,
    The downside, of course, is that something like []int{-1, -1} is a
    much less common, less obvious, and uglier-to-code-around sentinel
    than nil.

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • David DENG at Sep 4, 2014 at 10:30 pm
    I don't think so. strings.Index (and friends) also returns -1 for not
    found. This is a very common used mark for searching functions.
    On Thursday, September 4, 2014 3:16:43 PM UTC-7, Caleb Spare wrote:

    If so, an array of [-1, -1] can express the result of not found in
    FindIndex,

    The downside, of course, is that something like []int{-1, -1} is a
    much less common, less obvious, and uglier-to-code-around sentinel
    than nil.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Nick Craig-Wood at Sep 5, 2014 at 9:16 am
    IMHO it should be returning a

    type FindResult struct {
         Start int
         End int
    }

    Which would be just as memory efficient as a [2]int

    Then you could define a NotFound method on it

    func (fr FindResult) NotFound() bool {
         return fr.Start < 0
    }
    On 04/09/14 23:29, David DENG wrote:
    I don't think so. strings.Index (and friends) also returns -1 for not
    found. This is a very common used mark for searching functions.
    On Thursday, September 4, 2014 3:16:43 PM UTC-7, Caleb Spare wrote:

    If so, an array of [-1, -1] can express the result of not found in
    FindIndex,

    The downside, of course, is that something like []int{-1, -1} is a
    much less common, less obvious, and uglier-to-code-around sentinel
    than nil.

    --
    You received this message because you are subscribed to the Google
    Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send
    an email to golang-nuts+unsubscribe@googlegroups.com
    For more options, visit https://groups.google.com/d/optout.

    --
    Nick Craig-Wood <nick@craig-wood.com> -- http://www.craig-wood.com/nick

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Rob Pike at Sep 5, 2014 at 4:39 pm
    Discuss away, but this is all hypothetical. The interface is fine as
    is and is not going to change.

    -rob

    On Fri, Sep 5, 2014 at 2:15 AM, Nick Craig-Wood wrote:
    IMHO it should be returning a

    type FindResult struct {
    Start int
    End int
    }

    Which would be just as memory efficient as a [2]int

    Then you could define a NotFound method on it

    func (fr FindResult) NotFound() bool {
    return fr.Start < 0
    }
    On 04/09/14 23:29, David DENG wrote:
    I don't think so. strings.Index (and friends) also returns -1 for not
    found. This is a very common used mark for searching functions.
    On Thursday, September 4, 2014 3:16:43 PM UTC-7, Caleb Spare wrote:

    If so, an array of [-1, -1] can express the result of not found in
    FindIndex,

    The downside, of course, is that something like []int{-1, -1} is a
    much less common, less obvious, and uglier-to-code-around sentinel
    than nil.

    --
    You received this message because you are subscribed to the Google
    Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send
    an email to golang-nuts+unsubscribe@googlegroups.com
    For more options, visit https://groups.google.com/d/optout.

    --
    Nick Craig-Wood <nick@craig-wood.com> -- http://www.craig-wood.com/nick

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedSep 4, '14 at 1:53p
activeSep 5, '14 at 4:39p
posts10
users6
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase