Mongoid::Extensions::ObjectId::Conversions#convert calls BSON::ObjectId.from_string, which raises BSON::InvalidObjectId if the supplied argument is illegal.
This is a real-world performance problem.
Raising makes sense for BSON::ObjectId.from_string, if the method expects callers only to pass BSON::ObjectId.legal? arguments. Ideally, BSON::ObjectId would provide another method for trying the conversion without raising (e.g., returning nil rather than raising in case of illegal argument).
But it doesn't make sense for Mongoid::Extensions::ObjectId::Conversions#convert to use this raising as flow control. Rather, at the very least, #convert should check that the argument is BSON::ObjectId.legal? before trying to convert it. #convert should avoid permitting BSON::ObjectId.from_string to raise unless that would really be an error (and not simply something #convert catches).