rav1e icon indicating copy to clipboard operation
rav1e copied to clipboard

Attach different lifetimes to the tile block struct and its data.

Open DiamondLovesYou opened this issue 6 years ago • 3 comments

So the tile block reference doesn't need to live as long as the data it "holds".

DiamondLovesYou avatar Aug 24 '19 19:08 DiamondLovesYou

Coverage Status

Coverage remained the same at 70.922% when pulling 5e6ce710a066eca3a47944c603decddec423a73e on legionella-rs:blk-ctx-lifetimes into dc34123f5316c66547d3cfbfb86855991db1a1ec on xiph:master.

coveralls avatar Aug 24 '19 19:08 coveralls

Do you have a future change in mind that this enables?

tdaede avatar Aug 26 '19 21:08 tdaede

In theory, it releases some unnecessary constraints. In practice, the lifetime parameters are exposed to the type, so every usage of the type needs to pass all of them (at least as '_).

So in the general case, instead of:

struct MyView<'a> {
    pub w: &'a W,
    pub x: &'a X,
    pub y: &'a Y,
    pub z: &'a Z,
}

You would get:

struct MyView<'a, 'b, 'c, 'd> {
    pub w: &'a W,
    pub x: &'b X,
    pub y: &'c Y,
    pub z: &'d Z,
}

And passing that type to a function:

fn f(v: &MyView<'_, '_, '_, '_>) { … }

Just for information, I initially implemented it with 2 lifetimes (with less constraints though) in tiling.78 (70bd1e5571a5069a7bba827a7530fcc73b216f53). I decided not to, because I considered it was not worth it, and change it in tiling.79 (2883c68120f27e810f66a367335fae556bf87c7b).

But of course, if there is a benefit, we could change it.

rom1v avatar Oct 01 '19 13:10 rom1v