bodoni / svg

Composer and parser for SVG
Other
302 stars 44 forks source link

Avoid string conversion when working with `Value` #70

Open tgross35 opened 1 year ago

tgross35 commented 1 year ago

Rather than having Value always be a String, something like this could be better:

enum Value {
    String(String),
    Integer(i64),
    Float(f64),
}

And then the From implementations would just set an Integer or Float. This would be nice because it means that numbers (which account for a lot of possible values) never have to allocate.

Doing deref to str wouldn't be the best thing with this change. Something like as_string() -> String might be better suited.

IvanUkhov commented 1 year ago

Thank you! I don't remember all the details off the top of my head, but that seems very much reasonable. If you want and have time, you could give it a try. I would be happy to review the PR.