Skip to content

Commit efad7bc

Browse files
authored
Bump version (#10)
To reflect the breaking change in 83b4218
1 parent febf66c commit efad7bc

4 files changed

Lines changed: 50 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Changelog
2+
This project follows semantic versioning (semver) 2.0.
3+
Any new features, or breaking changes, will be written in this file.
4+
Bugfixes, internal refactors, documentation improvements and style changes will
5+
not be mentioned here, because they do not impact how the package is to be used.
6+
7+
## 0.3.0
8+
### Breaking changes
9+
* Change the bounds checking behaviour of the find* functions to match those of
10+
`Vector`. In particular, previously, `findnext(pred, mem, -5)` would be
11+
equivalent to searching from index 1, and similarly, `findprev(pred, mem,
12+
lastindex(mem) + 10)` would be equialent to searching from `lastindex(mem)`.
13+
Now, searching from an index before the first valid index throws a `BoundsError`.
14+
Findfirst searching from `i > lastindex(mem)`, and findlast searching from
15+
`i < 1` will still simply return `nothing`, just like searching vectors.
16+
17+
### Other changes
18+
* Add optimised versions of `findprev` and `findlast`, searching bytes
19+
* Add optimised version of `find*(iszero, bytes)` methods
20+
* Add optimised generic `find*` methods
21+
* Add functions `split_first`, `split_last`, `split_at` and `split_unaligned`
22+
* Add a more correct implementation of `Base.mightalias` for memory views and
23+
some types of arrays
24+
25+
26+

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "MemoryViews"
22
uuid = "a791c907-b98b-4e44-8f4d-e4c2362c6b2f"
3-
version = "0.2.2"
3+
version = "0.3.0"
44
authors = ["Jakob Nybo Nissen <jakobnybonissen@gmail.com>"]
55

66
[weakdeps]

src/basic.jl

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,10 @@ Base.elsize(::Type{<:MemoryView{T}}) where {T} = Base.elsize(Memory{T})
6060
Base.sizeof(x::MemoryView) = Base.elsize(typeof(x)) * length(x)
6161
Base.strides(::MemoryView) = (1,)
6262

63-
function Base.mightalias(a::MemoryView, b::MemoryView)
63+
# For two distinct element types, they can't alias
64+
Base.mightalias(::MemoryView, ::MemoryView) = false
65+
66+
function Base.mightalias(a::MemoryView{T}, b::MemoryView{T}) where {T}
6467
(isempty(a) | isempty(b)) && return false
6568
parent(a) === parent(b) || return false
6669
(p1, p2) = (pointer(a), pointer(b))
@@ -72,6 +75,19 @@ function Base.mightalias(a::MemoryView, b::MemoryView)
7275
end
7376
end
7477

78+
# We don't include strings here because this union is used for mightalias
79+
# checks, which are done implicitly, and we don't want to construct memory
80+
# views from strings implicitly, since that currently allocates.
81+
const KNOWN_MEM_BACKED = Union{Array, Memory, ContiguousSubArray}
82+
83+
function Base.mightalias(a::MemoryView, b::KNOWN_MEM_BACKED)
84+
Base.mightalias(a, ImmutableMemoryView(b))
85+
end
86+
87+
function Base.mightalias(a::KNOWN_MEM_BACKED, b::MemoryView)
88+
Base.mightalias(ImmutableMemoryView(a), b)
89+
end
90+
7591
function Base.getindex(v::MemoryView, idx::AbstractUnitRange)
7692
# This branch is necessary, because the memoryref can't point out of bounds.
7793
# So if the user gives an empty slice that is out of bounds, the boundscheck

test/runtests.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@ end
9696
@test Base.mightalias(MemoryView(v), MemoryView(v2))
9797
@test Base.mightalias(MemoryView(v), MemoryView(view(v, 7:8)))
9898
@test !Base.mightalias(MemoryView(v1), MemoryView(view(v, 7:8)))
99+
100+
v1 = [1, 2, 3]
101+
v2 = UInt[1, 2, 3]
102+
@test !Base.mightalias(v1, v2)
103+
@test Base.mightalias(MemoryView(v1)[2:2], v1)
104+
@test Base.mightalias(view(v1, 2:3), MemoryView(v1))
99105
end
100106

101107
# Span of views

0 commit comments

Comments
 (0)