RmlUi icon indicating copy to clipboard operation
RmlUi copied to clipboard

Getting rid of the Stream class, simplify URL and FileInterface

Open mikke89 opened this issue 5 years ago • 6 comments

I just don't really see the benefits of the Stream class. We are not loading files so big that they need to be streamed in parts. And we don't really need support for Write() and several other functions that are implemented.

The parsing in particular could be simplified a lot (and probably made faster) by just using a String or StringView in the necessary places.

Anybody have objections to this?

Similarly, the URL class is very big and overly generalized. Do we really need parameters, login/password fields? Perhaps it can all be replaced by a simple URL string, and a way to combine two URLs to resolve relative paths. This is lower priority though, as it doesn't really complicate the rest of the codebase. It's really big though, over 400 bytes here.

Finally, the FileInterface is really only used internally to read in whole files at a time. Thus, why not replace it with a single method to do exactly this?

mikke89 avatar Mar 08 '20 14:03 mikke89

I quite like the URL class and use it a lot in our web integration glue. Please keep it as it is!

viciious avatar Mar 10 '20 07:03 viciious

Finally, the FileInterface is really only used internally to read in whole files at a time. Thus, why not replace it with a single method to do exactly this?

This would involve some allocation/memory management on the app side.. Overall, either way would work fine for me.

viciious avatar Mar 10 '20 07:03 viciious

Sounds good, I'll keep the URL interface at least. I might try to improve the backend while keeping the API. We'll see se about the the Stream and File interface.

mikke89 avatar Mar 12 '20 22:03 mikke89

I rewrote my own version lua binding, and found a raw pointer for data block would be better than a Stream object.

btw, ElementDocument::ProcessHeader would try to open external script first, and pass the stream (if open success) into plugin.

https://github.com/mikke89/RmlUi/blob/master/Source/Core/ElementDocument.cpp#L133-L134

I think passing the filename into plugin is enough, so that the plugin can load the file by itself, and it can do something when the script can't open.

cloudwu avatar Nov 07 '20 01:11 cloudwu

@cloudwu I think you are referring to this PR: https://github.com/mikke89/RmlUi/pull/144 which has now been merged :)

mikke89 avatar Nov 11 '20 22:11 mikke89

Thanks . actboy168 is my colleague , and we are on the same project :)

cloudwu avatar Nov 11 '20 23:11 cloudwu