Have you tested this on meshes which don't have "P"? It used to report an error but it now looks like it'll crash. The Primitive::variableData() method is a handy convenience method for getting at the data and returning null if it doesn't exist.