Click here to Skip to main content
16,016,022 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: My uncle fell down the stairs... Pin
kmoorevs13-Sep-24 8:52
kmoorevs13-Sep-24 8:52 
GeneralRe: My uncle fell down the stairs... Pin
TNCaver16-Sep-24 4:32
TNCaver16-Sep-24 4:32 
GeneralRe: My uncle fell down the stairs... Pin
Nelek13-Sep-24 6:01
protectorNelek13-Sep-24 6:01 
GeneralRe: My uncle fell down the stairs... Pin
CPallini13-Sep-24 7:31
mveCPallini13-Sep-24 7:31 
GeneralRe: My uncle fell down the stairs... Pin
Sander Rossel15-Sep-24 22:20
professionalSander Rossel15-Sep-24 22:20 
GeneralRe: My uncle fell down the stairs... Pin
jmaida13-Sep-24 17:09
jmaida13-Sep-24 17:09 
GeneralRe: My uncle fell down the stairs... Pin
Craig Robbins15-Sep-24 3:24
Craig Robbins15-Sep-24 3:24 
GeneralWoohoo, peephole parsing big content Pin
honey the codewitch12-Sep-24 23:16
mvahoney the codewitch12-Sep-24 23:16 
I am rewriting my entire SVG parsing to be able to peephole parse the entire thing using a 64 byte capture buffer. (Or more, but 64 bytes is the minimum)

This creates an interesting problem when it comes to really long attributes like the "d" attribute on the "path" element in SVG.

XML
<path d="M-8.2 249.201C-8.2 249.201 -9 247.201 -13.4 246.801C-13.4 246.801 -35.8 243.201 -44.2 230.801C-44.2 230.801 -51 225.201 -46.6 236.801C-46.6 236.801 -36.2 257.201 -29.4 260.001C-29.4 260.001 -13 264.001 -8.2 249.201z"/>


The trick is the peephole parser returns about 64 bytes of that "d" attribute's value at a time. To read the entire "d" attribute will typically require multiple calls to read()

Well, I did it. With judicious use of state machines I can parse a float, skip whitespace, and parse path commands even they land partly across the 64 byte capture boundary.

Previously in my old code, I would gather all of the capture into one big string buffer and parse that.

This new approach wasn't easy code, but the result is very memory efficient, and robust in that it can handle content of any length with a constant (and very small) amount of memory.

Bless state machines. I have 7 states in my float parser alone.

I feel like I had my Wheaties this morning. Hooah!
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix

GeneralRe: Woohoo, peephole parsing big content Pin
BernardIE531713-Sep-24 1:06
BernardIE531713-Sep-24 1:06 
GeneralRe: Woohoo, peephole parsing big content Pin
honey the codewitch13-Sep-24 3:42
mvahoney the codewitch13-Sep-24 3:42 
GeneralRe: Woohoo, peephole parsing big content Pin
Matthew Dennis13-Sep-24 3:14
sysadminMatthew Dennis13-Sep-24 3:14 
GeneralThe Daily insider, things are getting really bad ... Pin
Richard MacCutchan12-Sep-24 22:50
mveRichard MacCutchan12-Sep-24 22:50 
GeneralRe: The Daily insider, things are getting really bad ... PinPopular
CodeProject13-Sep-24 3:36
CodeProject13-Sep-24 3:36 
GeneralRe: The Daily insider, things are getting really bad ... Pin
dandy7213-Sep-24 3:59
dandy7213-Sep-24 3:59 
GeneralRe: The Daily insider, things are getting really bad ... Pin
TNCaver13-Sep-24 4:28
TNCaver13-Sep-24 4:28 
JokeRe: The Daily insider, things are getting really bad ... Pin
Nelek13-Sep-24 6:04
protectorNelek13-Sep-24 6:04 
GeneralI threw a boomerang ... Pin
BernardIE531712-Sep-24 21:00
BernardIE531712-Sep-24 21:00 
GeneralRe: I threw a boomerang ... Pin
CPallini12-Sep-24 21:30
mveCPallini12-Sep-24 21:30 
GeneralRe: I threw a boomerang ... Pin
Sander Rossel12-Sep-24 23:33
professionalSander Rossel12-Sep-24 23:33 
GeneralRe: I threw a boomerang ... Pin
MarkTJohnson13-Sep-24 3:48
professionalMarkTJohnson13-Sep-24 3:48 
GeneralRe: I threw a boomerang ... Pin
obermd13-Sep-24 3:52
obermd13-Sep-24 3:52 
GeneralRe: I threw a boomerang ... Pin
Gary Stachelski 202113-Sep-24 6:03
Gary Stachelski 202113-Sep-24 6:03 
GeneralRe: I threw a boomerang ... Pin
Nelek13-Sep-24 10:01
protectorNelek13-Sep-24 10:01 
GeneralRe: I threw a boomerang ... Pin
Gary Stachelski 202113-Sep-24 12:04
Gary Stachelski 202113-Sep-24 12:04 
GeneralRe: I threw a boomerang ... Pin
FreedMalloc13-Sep-24 12:27
FreedMalloc13-Sep-24 12:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.