Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. Optimized (?)

Optimized (?)

Scheduled Pinned Locked Moved The Lounge
algorithmsdebuggingxmlperformancehelp
15 Posts 9 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    James Simpson
    wrote on last edited by
    #1

    Spot the Difference.... The optimizer got a bit carried away with this: (Excuse the tab's - cant seem to get that working!) The problem is in the "QUEUES FAILED" message Debug Build:

    public SOAPResult CreateTable(PosResource resource)
    {
    // right then, time to lock the
    // table

    int		resultCode = 1;
    string	resultText = string.Empty;
    
    string tablesFolder = ConfigurationSettings.AppSettings\[TABLES\_FOLDER\_KEY\];
    
    //	get the table file
    string tableFile = Path.Combine(tablesFolder, 
    	string.Format("{0}.xml", resource.Name));
    string lockFile = Path.Combine(tablesFolder, 
    	string.Format("{0}.{1}", resource.Name, 
    	resource.OriginatingTillId));
    
    if(File.Exists(tableFile))
    {
    	resultCode = -1;
    	resultText = "TABLE EXISTS";
    }
    else
    {
    	//	create the message envelope for the lock
    	MessageEnvelope	envelope
    	   = new MessageEnvelope(MessageType.Lock, resource);
    	//	attempt to write the queues (apart from central)
    	if(MessagingHelper.WriteEnvelopeToAllQueues(envelope,
    		 false))
    	{
    		//	create the lock
    		using(File.CreateText(lockFile))
    		{
    			//	release
    		}
    
    		//	create the table
    		using(File.CreateText(tableFile))
    		{
    			//	release
    		}
    	}
    	else
    	{
    		resultCode = -1;
    		resultText = "QUEUES FAILED";
    	}
    }
    
    return new SOAPResult(resultCode, resultText);
    

    }

    Decompiled Release Build with some strange optimization

    public SOAPResult CreateTable(PosResource resource)
    {
    int num1 = 1;
    string text1 = string.Empty;
    string text2 = ConfigurationSettings.AppSettings
    ["SOAPInterface.TableInterface.TablesFolder"];
    string text3 = Path.Combine(text2, string.Format("{0}.xml",
    resource.Name));
    string text4 = Path.Combine(text2, string.Format("{0}.{1}",
    resource.Name, resource.OriginatingTillId));
    if (File.Exists(text3))
    {
    num1 = -1;
    text1 = "TABLE EXISTS";
    }
    else
    {
    MessageEnvelope envelope1
    = new MessageEnvelope(MessageType.Lock, resource);
    if (MessagingHelper.WriteEnvelopeToAllQueues(envelope1,
    false))
    {
    StreamWriter writer1 = File.CreateText(text4);
    if (writer1 != null)
    {
    writer1.Dispose();
    }
    writer1 = File.CreateText(text3);
    if (writer1 != null)
    {
    writer1.Dispose();
    }

    L D L 3 Replies Last reply
    0
    • J James Simpson

      Spot the Difference.... The optimizer got a bit carried away with this: (Excuse the tab's - cant seem to get that working!) The problem is in the "QUEUES FAILED" message Debug Build:

      public SOAPResult CreateTable(PosResource resource)
      {
      // right then, time to lock the
      // table

      int		resultCode = 1;
      string	resultText = string.Empty;
      
      string tablesFolder = ConfigurationSettings.AppSettings\[TABLES\_FOLDER\_KEY\];
      
      //	get the table file
      string tableFile = Path.Combine(tablesFolder, 
      	string.Format("{0}.xml", resource.Name));
      string lockFile = Path.Combine(tablesFolder, 
      	string.Format("{0}.{1}", resource.Name, 
      	resource.OriginatingTillId));
      
      if(File.Exists(tableFile))
      {
      	resultCode = -1;
      	resultText = "TABLE EXISTS";
      }
      else
      {
      	//	create the message envelope for the lock
      	MessageEnvelope	envelope
      	   = new MessageEnvelope(MessageType.Lock, resource);
      	//	attempt to write the queues (apart from central)
      	if(MessagingHelper.WriteEnvelopeToAllQueues(envelope,
      		 false))
      	{
      		//	create the lock
      		using(File.CreateText(lockFile))
      		{
      			//	release
      		}
      
      		//	create the table
      		using(File.CreateText(tableFile))
      		{
      			//	release
      		}
      	}
      	else
      	{
      		resultCode = -1;
      		resultText = "QUEUES FAILED";
      	}
      }
      
      return new SOAPResult(resultCode, resultText);
      

      }

      Decompiled Release Build with some strange optimization

      public SOAPResult CreateTable(PosResource resource)
      {
      int num1 = 1;
      string text1 = string.Empty;
      string text2 = ConfigurationSettings.AppSettings
      ["SOAPInterface.TableInterface.TablesFolder"];
      string text3 = Path.Combine(text2, string.Format("{0}.xml",
      resource.Name));
      string text4 = Path.Combine(text2, string.Format("{0}.{1}",
      resource.Name, resource.OriginatingTillId));
      if (File.Exists(text3))
      {
      num1 = -1;
      text1 = "TABLE EXISTS";
      }
      else
      {
      MessageEnvelope envelope1
      = new MessageEnvelope(MessageType.Lock, resource);
      if (MessagingHelper.WriteEnvelopeToAllQueues(envelope1,
      false))
      {
      StreamWriter writer1 = File.CreateText(text4);
      if (writer1 != null)
      {
      writer1.Dispose();
      }
      writer1 = File.CreateText(text3);
      if (writer1 != null)
      {
      writer1.Dispose();
      }

      L Offline
      L Offline
      Luis Alonso Ramos
      wrote on last edited by
      #2

      Why has this been voted down? I don't see it as a programming question but more like a "hey, look what happened to my code! I guess is a compiler bug". If he were asking on what to do to fix it, it would be a programming question. But not this... or so I think! -- LuisR


      Luis Alonso Ramos Intelectix - Chihuahua, Mexico Not much here: My CP Blog!

      J 1 Reply Last reply
      0
      • J James Simpson

        Spot the Difference.... The optimizer got a bit carried away with this: (Excuse the tab's - cant seem to get that working!) The problem is in the "QUEUES FAILED" message Debug Build:

        public SOAPResult CreateTable(PosResource resource)
        {
        // right then, time to lock the
        // table

        int		resultCode = 1;
        string	resultText = string.Empty;
        
        string tablesFolder = ConfigurationSettings.AppSettings\[TABLES\_FOLDER\_KEY\];
        
        //	get the table file
        string tableFile = Path.Combine(tablesFolder, 
        	string.Format("{0}.xml", resource.Name));
        string lockFile = Path.Combine(tablesFolder, 
        	string.Format("{0}.{1}", resource.Name, 
        	resource.OriginatingTillId));
        
        if(File.Exists(tableFile))
        {
        	resultCode = -1;
        	resultText = "TABLE EXISTS";
        }
        else
        {
        	//	create the message envelope for the lock
        	MessageEnvelope	envelope
        	   = new MessageEnvelope(MessageType.Lock, resource);
        	//	attempt to write the queues (apart from central)
        	if(MessagingHelper.WriteEnvelopeToAllQueues(envelope,
        		 false))
        	{
        		//	create the lock
        		using(File.CreateText(lockFile))
        		{
        			//	release
        		}
        
        		//	create the table
        		using(File.CreateText(tableFile))
        		{
        			//	release
        		}
        	}
        	else
        	{
        		resultCode = -1;
        		resultText = "QUEUES FAILED";
        	}
        }
        
        return new SOAPResult(resultCode, resultText);
        

        }

        Decompiled Release Build with some strange optimization

        public SOAPResult CreateTable(PosResource resource)
        {
        int num1 = 1;
        string text1 = string.Empty;
        string text2 = ConfigurationSettings.AppSettings
        ["SOAPInterface.TableInterface.TablesFolder"];
        string text3 = Path.Combine(text2, string.Format("{0}.xml",
        resource.Name));
        string text4 = Path.Combine(text2, string.Format("{0}.{1}",
        resource.Name, resource.OriginatingTillId));
        if (File.Exists(text3))
        {
        num1 = -1;
        text1 = "TABLE EXISTS";
        }
        else
        {
        MessageEnvelope envelope1
        = new MessageEnvelope(MessageType.Lock, resource);
        if (MessagingHelper.WriteEnvelopeToAllQueues(envelope1,
        false))
        {
        StreamWriter writer1 = File.CreateText(text4);
        if (writer1 != null)
        {
        writer1.Dispose();
        }
        writer1 = File.CreateText(text3);
        if (writer1 != null)
        {
        writer1.Dispose();
        }

        D Offline
        D Offline
        Dave Kreskowiak
        wrote on last edited by
        #3

        Did you not see the big red message at the top of the window when you posted this? Please do NOT post programming questions or ads to this forum. This would have been more appropriate in the C# Forum. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

        D 1 Reply Last reply
        0
        • D Dave Kreskowiak

          Did you not see the big red message at the top of the window when you posted this? Please do NOT post programming questions or ads to this forum. This would have been more appropriate in the C# Forum. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

          D Offline
          D Offline
          David Wulff
          wrote on last edited by
          #4

          It was not a programming question... If you took the time to determine it was C# code, you might have taken the time to read the message too.


          Ðavid Wulff Audioscrobbler :: flickr Die Freiheit spielt auf allen Geigen (video)

          R P D 3 Replies Last reply
          0
          • L Luis Alonso Ramos

            Why has this been voted down? I don't see it as a programming question but more like a "hey, look what happened to my code! I guess is a compiler bug". If he were asking on what to do to fix it, it would be a programming question. But not this... or so I think! -- LuisR


            Luis Alonso Ramos Intelectix - Chihuahua, Mexico Not much here: My CP Blog!

            J Offline
            J Offline
            Jon Newman
            wrote on last edited by
            #5

            It has code in it and makes me scroll the page down when open. Thus it is as bad as any programming question.


            Jonathan 'nonny' Newman blog.nonny.com [^]

            1 Reply Last reply
            0
            • J James Simpson

              Spot the Difference.... The optimizer got a bit carried away with this: (Excuse the tab's - cant seem to get that working!) The problem is in the "QUEUES FAILED" message Debug Build:

              public SOAPResult CreateTable(PosResource resource)
              {
              // right then, time to lock the
              // table

              int		resultCode = 1;
              string	resultText = string.Empty;
              
              string tablesFolder = ConfigurationSettings.AppSettings\[TABLES\_FOLDER\_KEY\];
              
              //	get the table file
              string tableFile = Path.Combine(tablesFolder, 
              	string.Format("{0}.xml", resource.Name));
              string lockFile = Path.Combine(tablesFolder, 
              	string.Format("{0}.{1}", resource.Name, 
              	resource.OriginatingTillId));
              
              if(File.Exists(tableFile))
              {
              	resultCode = -1;
              	resultText = "TABLE EXISTS";
              }
              else
              {
              	//	create the message envelope for the lock
              	MessageEnvelope	envelope
              	   = new MessageEnvelope(MessageType.Lock, resource);
              	//	attempt to write the queues (apart from central)
              	if(MessagingHelper.WriteEnvelopeToAllQueues(envelope,
              		 false))
              	{
              		//	create the lock
              		using(File.CreateText(lockFile))
              		{
              			//	release
              		}
              
              		//	create the table
              		using(File.CreateText(tableFile))
              		{
              			//	release
              		}
              	}
              	else
              	{
              		resultCode = -1;
              		resultText = "QUEUES FAILED";
              	}
              }
              
              return new SOAPResult(resultCode, resultText);
              

              }

              Decompiled Release Build with some strange optimization

              public SOAPResult CreateTable(PosResource resource)
              {
              int num1 = 1;
              string text1 = string.Empty;
              string text2 = ConfigurationSettings.AppSettings
              ["SOAPInterface.TableInterface.TablesFolder"];
              string text3 = Path.Combine(text2, string.Format("{0}.xml",
              resource.Name));
              string text4 = Path.Combine(text2, string.Format("{0}.{1}",
              resource.Name, resource.OriginatingTillId));
              if (File.Exists(text3))
              {
              num1 = -1;
              text1 = "TABLE EXISTS";
              }
              else
              {
              MessageEnvelope envelope1
              = new MessageEnvelope(MessageType.Lock, resource);
              if (MessagingHelper.WriteEnvelopeToAllQueues(envelope1,
              false))
              {
              StreamWriter writer1 = File.CreateText(text4);
              if (writer1 != null)
              {
              writer1.Dispose();
              }
              writer1 = File.CreateText(text3);
              if (writer1 != null)
              {
              writer1.Dispose();
              }

              L Offline
              L Offline
              leppie
              wrote on last edited by
              #6

              Sure its not just the decompiling software you are using? Reflector has a few such bugs. Eg Code: inputBuffer[i] ^= outputBuffer[i]; Reconstructed code: (buffer2 = inputBuffer)[(int) (ptr1 = (IntPtr) num1)] = (byte) (buffer2[(int) ptr1] ^ outputBuffer[num1]); All 'buffer' are byte[]. xacc-ide 0.0.15 now with C#, MSIL, C, XML, ASP.NET, Nemerle, MyXaml and HLSL coloring - Screenshots

              J 1 Reply Last reply
              0
              • D David Wulff

                It was not a programming question... If you took the time to determine it was C# code, you might have taken the time to read the message too.


                Ðavid Wulff Audioscrobbler :: flickr Die Freiheit spielt auf allen Geigen (video)

                R Offline
                R Offline
                Rocky Moore
                wrote on last edited by
                #7

                Actually though, wouldn't it make more sense in the C$ forum? Rocky <>< My Blog[^]

                D 1 Reply Last reply
                0
                • D David Wulff

                  It was not a programming question... If you took the time to determine it was C# code, you might have taken the time to read the message too.


                  Ðavid Wulff Audioscrobbler :: flickr Die Freiheit spielt auf allen Geigen (video)

                  P Offline
                  P Offline
                  peterchen
                  wrote on last edited by
                  #8

                  David Wulff wrote: It was not a programming question... But it's like... just imagine for a moment you are a hard working lumberjack. After a hard day of hard work (jacking lumber?) you sit down in the pub with your lumberjack buddies, and chill with a beer, and discussing important things like suspenders brand, bra sizes and shopping. In comes Joe Lumberjack Doe, and starts talking about cubic feet and machines and oil and stuff. No, it was not a programming question, and I'd like to see more such things in the lounge, but most loungers want their lounge free of code.


                  Pandoras Gift #44: Hope. The one that keeps you on suffering.
                  aber.. "Wie gesagt, der Scheiss is' Therapie"
                  boost your code || Fold With Us! || sighist | doxygen

                  1 Reply Last reply
                  0
                  • D David Wulff

                    It was not a programming question... If you took the time to determine it was C# code, you might have taken the time to read the message too.


                    Ðavid Wulff Audioscrobbler :: flickr Die Freiheit spielt auf allen Geigen (video)

                    D Offline
                    D Offline
                    Dave Kreskowiak
                    wrote on last edited by
                    #9

                    Not really. The ton of semi-colons was a dead giveaway without even reading a single line of code. I stand by what I posted simply because the end result of his post had way too much potential of breaking down into a programming dialog. I really don't give a crap if I got rated a 1 or not. I posted what I was thinking. Isn't that what the Lounge is all about? :) RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

                    G D 2 Replies Last reply
                    0
                    • D Dave Kreskowiak

                      Not really. The ton of semi-colons was a dead giveaway without even reading a single line of code. I stand by what I posted simply because the end result of his post had way too much potential of breaking down into a programming dialog. I really don't give a crap if I got rated a 1 or not. I posted what I was thinking. Isn't that what the Lounge is all about? :) RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

                      G Offline
                      G Offline
                      Gary Kirkham
                      wrote on last edited by
                      #10

                      Dave Kreskowiak wrote: The ton of semi-colons was a dead giveaway without even reading a single line of code. C# is the only language with semi-colons? :rolleyes: You have to read at least a little code to know it's C# ;P Gary Kirkham Forever Forgiven and Alive in the Spirit He is no fool who gives what he cannot keep to gain what he cannot lose. - Jim Elliot Me blog, You read

                      1 Reply Last reply
                      0
                      • R Rocky Moore

                        Actually though, wouldn't it make more sense in the C$ forum? Rocky <>< My Blog[^]

                        D Offline
                        D Offline
                        David Wulff
                        wrote on last edited by
                        #11

                        Well I took his post to mean "look at this crazy thing!" which has been done safely in the Lounge since it began. If it was in the C# forum it would only get C# developers looking at it, which is not what he wanted.


                        Ðavid Wulff Audioscrobbler :: flickr Die Freiheit spielt auf allen Geigen (video)

                        1 Reply Last reply
                        0
                        • D Dave Kreskowiak

                          Not really. The ton of semi-colons was a dead giveaway without even reading a single line of code. I stand by what I posted simply because the end result of his post had way too much potential of breaking down into a programming dialog. I really don't give a crap if I got rated a 1 or not. I posted what I was thinking. Isn't that what the Lounge is all about? :) RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

                          D Offline
                          D Offline
                          David Wulff
                          wrote on last edited by
                          #12

                          A post having potential of breaking down into a programmming dialogue does not making something a programming question. If we ban everything related to software development, the Lounge will have no content. That is afterall what we do. Far too many people are overly sensitive to jumping on people asking innocent questions or, in this case, showing us something stupid the compiler did. We've had posts talking about new features in future versions of C#, how to code Greasemonkey scripts, all sorts of things that were similar in content to James' post, and they were all allowed with a lynching. Heck this morning I posted a link to a Daily WTF entry which was precisely what this thread was meant to be, and I got voted consecutive 5's for it. Why? Well probably because I didn't draw attention to it by using <pre> blocks, otherwise it too would have attracted the kneejerk 1 voters. The technical forums are for techical questions/advice, not stuff like this.


                          Ðavid Wulff Audioscrobbler :: flickr Die Freiheit spielt auf allen Geigen (video)

                          1 Reply Last reply
                          0
                          • L leppie

                            Sure its not just the decompiling software you are using? Reflector has a few such bugs. Eg Code: inputBuffer[i] ^= outputBuffer[i]; Reconstructed code: (buffer2 = inputBuffer)[(int) (ptr1 = (IntPtr) num1)] = (byte) (buffer2[(int) ptr1] ^ outputBuffer[num1]); All 'buffer' are byte[]. xacc-ide 0.0.15 now with C#, MSIL, C, XML, ASP.NET, Nemerle, MyXaml and HLSL coloring - Screenshots

                            J Offline
                            J Offline
                            James Simpson
                            wrote on last edited by
                            #13

                            I decompiled it becuase the code was executing incorrectly, basically it was returning the error condition always. The optimizer actually changed the logic! :) James Simpson Web Developer imebgo@hotmail.com P S - This is what part of the alphabet would look like if Q and R were eliminated
                            Mitch Hedberg

                            L 1 Reply Last reply
                            0
                            • J James Simpson

                              I decompiled it becuase the code was executing incorrectly, basically it was returning the error condition always. The optimizer actually changed the logic! :) James Simpson Web Developer imebgo@hotmail.com P S - This is what part of the alphabet would look like if Q and R were eliminated
                              Mitch Hedberg

                              L Offline
                              L Offline
                              leppie
                              wrote on last edited by
                              #14

                              That WriteToAllQueues function, does it return the 2nd parameter unchanged perhaps? xacc-ide 0.0.15 now with C#, MSIL, C, XML, ASP.NET, Nemerle, MyXaml and HLSL coloring - Screenshots

                              J 1 Reply Last reply
                              0
                              • L leppie

                                That WriteToAllQueues function, does it return the 2nd parameter unchanged perhaps? xacc-ide 0.0.15 now with C#, MSIL, C, XML, ASP.NET, Nemerle, MyXaml and HLSL coloring - Screenshots

                                J Offline
                                J Offline
                                James Simpson
                                wrote on last edited by
                                #15

                                It returns a True, which is a successfully write. It makes you wonder about the optimizer really, it could introduce subtle problems with release code. James Simpson Web Developer imebgo@hotmail.com P S - This is what part of the alphabet would look like if Q and R were eliminated
                                Mitch Hedberg

                                1 Reply Last reply
                                0
                                Reply
                                • Reply as topic
                                Log in to reply
                                • Oldest to Newest
                                • Newest to Oldest
                                • Most Votes


                                • Login

                                • Don't have an account? Register

                                • Login or register to search.
                                • First post
                                  Last post
                                0
                                • Categories
                                • Recent
                                • Tags
                                • Popular
                                • World
                                • Users
                                • Groups