On Fri, Mar 9, 2012 at 11:39 AM, Twan van Laarhoven <[email protected]> wrote: > Quick follow up question: > > Are unsafeThawArray# and unsafeFreezeArray# guaranteed to not make a copy? > I.e. are these two pieces of code equivalent with respect to further usage > of the return value: > > do mary <- unsafeThawArray# ary > writeArray# mary 123# newValue > unsafeFreezeArray# mary > > and > > do mary <- unsafeThawArray# ary > writeArray# mary 123# newValue > return ary > > (where do notation is actually done manually.)
I believe you * don't have to use the return value from unsafeFreezeArray#, you can use the (now mutated) Array# initially passed to unsafeThawArray#, but * you must call unsafeFreezeArray# to make sure the header of the heap object is updated correctly. At least this is what I did in unordered-containers here: https://github.com/tibbe/unordered-containers/commit/428885cb1a62123921c22bc21da9ff385e797686 Cheers, Johan _______________________________________________ Glasgow-haskell-users mailing list [email protected] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
