performance tuning – perform logical or on sublist of a list efficiently


Given a huge list x of 0s and 1s and an increasing list i of positions, which partitions x into (possibly empty) sublists, I wish to return a list, which has 1 if the corresponding sublist contains a 1, and 0 otherwise. In other words, perform logical ‘or’ on sublists.

The following code does what I want, but is somewhat inefficient:

n=10^9; AbsoluteTiming@MaxMemoryUsed(x=RandomChoice({0,0,0,0,0,0,1},n);
i=Sort({1}~Join~RandomInteger({0,n},n/10)~Join~{n}))
AbsoluteTiming@MaxMemoryUsed(y=TakeList(x,i((2;;))-i((;;-2))))
AbsoluteTiming@MaxMemoryUsed(y=Clip(Plus@@#& /@y))

Is there a better way of doing this?