parispurchase / json-io

Automatically exported from code.google.com/p/json-io
0 stars 0 forks source link

maybe unnecessary call of convertParsedMapsToJava inside JsonReader.readObject() #18

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What version of the product are you using? On what operating system?
2.6.1, Suse Linux

Please provide any additional information below.

if I don't want to have the java object, but only the map representation of the 
json (by giving the constructor 'true' for noObjects), convertParsedMapsToJava 
is still invoked - is this necessary or simply an unnecessary overhead in this 
case? This is the readObject() code from JsonReader:

    public Object readObject() throws IOException
    {
        Object o = readJsonObject();
        if (o == EMPTY_OBJECT)
        {
            return new JsonObject();
        }

        Object graph = convertParsedMapsToJava((JsonObject) o);

        // Allow a complete 'Map' return (Javascript style)
        if (_noObjects)
        {
            return o;
        }
        return graph;
    }

Maybe it could be more efficient if convertParsedMapsToJava is only invoked if 
necessary:

    public Object readObject() throws IOException
    {
        Object o = readJsonObject();
        if (o == EMPTY_OBJECT)
        {
            return new JsonObject();
        }

        // Allow a complete 'Map' return (Javascript style)
        if (_noObjects)
        {
            return o;
        }

        Object graph = convertParsedMapsToJava((JsonObject) o);

        return graph;
    }

Original issue reported on code.google.com by christia...@gmail.com on 8 Jul 2014 at 1:04